From 6124ad694abcb0842ff7ae3b966c13488378277a Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Wed, 4 Oct 2023 15:41:05 +0000 Subject: [PATCH] the effect of yield_now() was just less competition in find_victim, prove by replacing it with busy loop --- pageserver/src/page_cache.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pageserver/src/page_cache.rs b/pageserver/src/page_cache.rs index c5c85aa5cb..b335d86d2b 100644 --- a/pageserver/src/page_cache.rs +++ b/pageserver/src/page_cache.rs @@ -892,7 +892,13 @@ impl PageCache { self.next_evict_slot.fetch_add(1, Ordering::Relaxed) % self.slots.len(); match (last_slot_idx, next_idx) { (Some(x), y) if x > y => { - tokio::task::yield_now().await; + #[inline(never)] + fn dont_compete_with_other_find_victim_for_a_while() { + for _ in 0..1_000_000 { + std::hint::spin_loop(); + } + } + dont_compete_with_other_find_victim_for_a_while(); } (None | Some(_), _) => {} }