-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actors not using multiple CPUs #42
Comments
For reference, this very similar version of the code which only uses use async_std::task;
const ACTORS: usize = 8;
async fn handle() -> usize {
let mut res: usize = 1;
for i in 2..100_000_000 {
res = res.wrapping_mul(i);
res /= i - 1;
}
res
}
#[async_std::main]
async fn main() {
let mut promises = Vec::with_capacity(ACTORS);
for _ in 0..ACTORS {
promises.push(task::spawn(handle()));
}
let mut res = 0;
for promise in promises {
res += promise.await;
};
println!("result: {}", res);
} Result:
|
I'm also interested in this. I'm searching for a system where you can have some actors running as corutines and some other actors running in their own threads, but I'm still not sure whether this crate would actually help with that. |
@wizeman I'm able to reproduce what you stated, but also reproduce the inverse of your observed results by changing the first example to for addr in children.into_iter() {
responses.push(xactor::spawn(async move {
addr.call(Calc).await
}));
} and the second example to promises.push(handle()); Not sure how that helps as I'm not too familiar with async/executor internals, but it seems that there are ways of mitigating what you've observed, and coercing lower performance behaviour. |
As far as I understand, on most actor implementations, different actors can process their own messages in parallel with respect to other actors, which makes things go faster.
But I can't seem to make xactor do that:
This is what I get:
Since AFAIU I am sending the messages to all the actors before starting to
await
their responses, I would have expected CPU usage to be around 800% on my 8-logical-core CPU rather than 99%.Am I doing something wrong or is this expected?
The text was updated successfully, but these errors were encountered: