Call multiple lookup operations async
eozturk1 opened this issue · comments
To improve the efficiency of bulk/multi lookups, we could call lookups async and await on the results of all lookups -- rather than awaiting on them individually.
Pulled from comment in PR #163
use futures::future;
// generate your vector of individual tasks by spawning them on green threads
// but you need to clone "self" in order to apply on different threads, which will
// shard the data-access pointer and cache pointers, etc to yield individual Directory<_>
// instances on each thread
let tasks = proofs_to_generate.into_iter().map(|proof| {
let self_clone = self.clone();
tokio::spawn(async move { self_clone.lookup(proof).await })
}
let outputs = future::try_join_all(tasks).await?;