-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use more than one CPU core in IPA #742
Comments
I want to try async_scoped. Yes, it is generally unsafe to have task scopes, but in our case it may be acceptable, because we don't use mem::forget in prod code. |
I made the initial prototype that uses for i in 0..10 {
spawner.spawn(async move { let record_id = RecordId::from(i); /* do something */ })
}
let results = spawner.collect().await; // results may appear in any order It is definitely happening in our tests when I plug in async_scoped // H1
collected results = [Ok((RecordId(1), (20_mod31, 22_mod31))), Ok((RecordId(0), (1_mod31, 20_mod31)))]
// H2
collected results = [Ok((RecordId(0), (20_mod31, 10_mod31))), Ok((RecordId(1), (22_mod31, 21_mod31)))]
// H3
collected results = [Ok((RecordId(0), (10_mod31, 1_mod31))), Ok((RecordId(1), (21_mod31, 20_mod31)))] There are several ways we can tackle this issue: Ignore and let caller's to re-order results for i in 0..10 {
spawner.spawn(async move { let record_id = RecordId::from(i); /* do something */ (record_id, meaningful_result) })
}
let mut results: Vec<(RecordId, _)> = spawner.collect().await;
// sort by record_id
results.sort_by(|a, b| a.record_id.cmp(&b.record_id));
// drop record_id
results.map(|a| a.1).collect() least favorite option, because of performance penalty and mental overhead. In IPA we mostly process things in order, so this code will have to appear everywhere where we process things in parallel Create a
|
#873 is the first attempt to address this |
Overview
Currently IPA is not capable of using more than one core at a time. Futures that we create while running a query are not spawned as executor's task, therefore they are all polled inside one thread. Multi-threaded Tokio runtime that we use just bounce the parent future and all its children between threads/cores but it only polls one future at a time.
All of the above makes IPA quite slow at the moment. One core does not generate enough work for the network layer and our throughput is quite miserable. We need to find a way how to parallelize work and leverage all (ok more than one) cores available on the host.
TODO: add more context and possible solutions
The text was updated successfully, but these errors were encountered: