Struggling with Bastion does not release memory after handling messages
Version: bastion v0.4.5 feature tokio-runtime / tokio v1.21 feature full / tokio-util v0.7 feature full
Platform: Linux 5.15.68.1-microsoft-standard-WSL2 x86_64 GNU/Linux
Subsystem: Ubuntu 20.04 LTS
Hi,
Now I am working with a project that uses Bastion as a core of actor model architect. I have used it once before but with this project I am running into a problem as I describe. Here is my little demonstration about it:
use std::time::Instant;
use bastion::prelude::*;
#[tokio::main(flavor = "multi_thread", worker_threads = 16)]
async fn main() {
let start = Instant::now();
Bastion::children(|children| {
children
.with_distributor(Distributor::named("test_actor"))
.with_redundancy(15)
.with_exec(|ctx| async move {
loop {
MessageHandler::new(ctx.recv().await?).on_tell(|msg: Vec<u8>, _| {
drop(msg);
});
}
})
})
.unwrap();
let sender = Bastion::children(|children| {
children.with_exec(|_| async {
let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(10));
loop {
interval.tick().await;
for _ in 0..3_000 {
Distributor::named("test_actor")
.tell_one(vec![0u8; 300])
.unwrap();
}
}
})
})
.unwrap();
Bastion::init();
Bastion::start();
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
sender.kill().unwrap();
println!("Running time: {:?}", start.elapsed());
let waiting = Instant::now();
std::io::stdin().read_line(&mut buf).unwrap();
println!("Waiting time: {:?}", waiting.elapsed());
Bastion::block_until_stopped();
}
Result
After start: memory is about 0.2%
After first std::io::stdin().read_line(&mut buf).unwrap();: Running time: 2488.367728948s - memory is about 0.5%
After second std::io::stdin().read_line(&mut buf).unwrap();: Waiting time: 792.050614104s - memory is being kept at 0.5%
Sorry for my information that could not be easy to analyze (I am still new to Rust and have not found a tool to measure memory yet 😓).
As you can see if I send 10_000 of messages at a time (each message is about 300 bytes (in practice is more than that)) the issue comes.
Hope someone could help me out of this soon. Did I do something wrong? Thanks in advance.
Struggling with Bastion does not release memory after handling messages
bastion v0.4.5
featuretokio-runtime
/tokio v1.21
featurefull
/tokio-util v0.7
featurefull
Hi,
Now I am working with a project that uses Bastion as a core of
actor model
architect. I have used it once before but with this project I am running into a problem as I describe. Here is my little demonstration about it:Result After start: memory is about 0.2% After first
std::io::stdin().read_line(&mut buf).unwrap();
:Running time: 2488.367728948s
- memory is about 0.5% After secondstd::io::stdin().read_line(&mut buf).unwrap();
:Waiting time: 792.050614104s
- memory is being kept at 0.5%Sorry for my information that could not be easy to analyze (I am still new to Rust and have not found a tool to measure memory yet 😓).
As you can see if I send
10_000
of messages at a time (each message is about 300 bytes (in practice is more than that)) the issue comes.Hope someone could help me out of this soon. Did I do something wrong? Thanks in advance.