Skip to content

Commit

Permalink
move maybe_evict_cache() off default rayon pool
Browse files Browse the repository at this point in the history
This can potentially block the pre_commit_ledger thread while it's
holding the buffered_state lock. Before we reduce the scope of that
lock, I'm moving this part off the defualt pool so that even if the
default pool gets busy (or worse, there are tasks on the threads of the
pool trying to lock the buffered_state) this part doesn't get affected.
  • Loading branch information
msmouse committed Oct 23, 2024
1 parent abc74ea commit 3b5cd91
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions storage/aptosdb/src/versioned_node_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{
fmt,
sync::Arc,
};
use aptos_experimental_runtimes::thread_manager::THREAD_MANAGER;

type NodeCache = HashMap<NodeKey, Node>;

Expand Down Expand Up @@ -73,14 +74,16 @@ impl VersionedNodeCache {
};

if let Some((version, cache)) = to_evict {
cache
.iter()
.collect::<Vec<_>>()
.into_par_iter()
.with_min_len(100)
.for_each(|(node_key, node)| {
lru_cache.put(node_key.clone(), node.clone());
});
THREAD_MANAGER.get_non_exe_cpu_pool().install(|| {
cache
.iter()
.collect::<Vec<_>>()
.into_par_iter()
.with_min_len(100)
.for_each(|(node_key, node)| {
lru_cache.put(node_key.clone(), node.clone());
});
});

let evicted = self.inner.write().pop_front();
assert_eq!(evicted, Some((version, cache)));
Expand Down

0 comments on commit 3b5cd91

Please sign in to comment.