From 3b5cd916536f62c3fd61da84cac5bd5644b36cb6 Mon Sep 17 00:00:00 2001 From: aldenhu Date: Wed, 23 Oct 2024 22:22:42 +0000 Subject: [PATCH] move maybe_evict_cache() off default rayon pool 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. --- storage/aptosdb/src/versioned_node_cache.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/storage/aptosdb/src/versioned_node_cache.rs b/storage/aptosdb/src/versioned_node_cache.rs index 8b935f1e77ab1..03f7778e28d83 100644 --- a/storage/aptosdb/src/versioned_node_cache.rs +++ b/storage/aptosdb/src/versioned_node_cache.rs @@ -11,6 +11,7 @@ use std::{ fmt, sync::Arc, }; +use aptos_experimental_runtimes::thread_manager::THREAD_MANAGER; type NodeCache = HashMap; @@ -73,14 +74,16 @@ impl VersionedNodeCache { }; if let Some((version, cache)) = to_evict { - cache - .iter() - .collect::>() - .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::>() + .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)));