From 87755bf80e6a87fd4fbe88bc67344a3156080022 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Thu, 12 Dec 2024 19:37:23 +0100 Subject: [PATCH] concurrent-futures: poll before pushing into FuturesUnordered (this will do io_uring submission in most cases) --- pageserver/src/tenant/storage_layer.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pageserver/src/tenant/storage_layer.rs b/pageserver/src/tenant/storage_layer.rs index c522e88b89..f56f9bf6e4 100644 --- a/pageserver/src/tenant/storage_layer.rs +++ b/pageserver/src/tenant/storage_layer.rs @@ -23,6 +23,7 @@ use std::future::Future; use std::ops::Range; use std::pin::Pin; use std::sync::Arc; +use std::task::Poll; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use utils::lsn::Lsn; @@ -182,7 +183,13 @@ impl IoConcurrency { tokio::spawn(fut); } IoConcurrency::FuturesUnordered { futures } => { - futures.push(Box::pin(fut)); + let mut fut = Box::pin(fut); + match futures::poll!(&mut fut) { + Poll::Ready(()) => {} + Poll::Pending => { + futures.push(fut); + } + } } } }