Revert "investigation: add log_if_slow => shows that the io_futures are slow"

This reverts commit e81fa7137e.
This commit is contained in:
Christian Schwarz
2025-01-15 19:34:37 +01:00
parent 40470c66cd
commit f8218ac5fc
2 changed files with 1 additions and 45 deletions

View File

@@ -375,48 +375,6 @@ async fn timed_after_cancellation<Fut: std::future::Future>(
}
}
async fn log_if_slow<Fut: std::future::Future>(
name: &str,
warn_after: std::time::Duration,
fut: Fut,
) -> <Fut as std::future::Future>::Output {
let started = std::time::Instant::now();
let mut fut = std::pin::pin!(fut);
match tokio::time::timeout(warn_after, &mut fut).await {
Ok(ret) => ret,
Err(_) => {
tracing::info!(
what = name,
elapsed_ms = started.elapsed().as_millis(),
"slow future"
);
let res = fut.await;
tracing::info!(
what = name,
elapsed_ms = started.elapsed().as_millis(),
"slow future completed"
);
res
}
}
}
pub(crate) trait LogIfSlowFutureExt: std::future::Future {
async fn log_if_slow(self, name: &'static str, warn_after: std::time::Duration) -> Self::Output
where
Self: Sized,
{
log_if_slow(name, warn_after, self).await
}
}
impl<Fut> LogIfSlowFutureExt for Fut where Fut: std::future::Future {}
#[cfg(test)]
mod timed_tests {
use super::timed;

View File

@@ -10,8 +10,6 @@ mod layer_desc;
mod layer_name;
pub mod merge_iterator;
use crate::LogIfSlowFutureExt;
use crate::context::{AccessStatsBehavior, RequestContext};
use bytes::Bytes;
use futures::stream::FuturesUnordered;
@@ -350,7 +348,7 @@ impl IoConcurrency {
match self {
IoConcurrency::Serial => fut.await,
IoConcurrency::FuturesUnordered { ios_tx, .. } => {
let fut = Box::pin(fut.log_if_slow("spawned_io", Duration::from_secs(1)));
let fut = Box::pin(fut);
// NB: experiments showed that doing an opportunistic poll of `fut` here was bad for throughput
// while insignificant for latency.
// It would make sense to revisit the tokio-epoll-uring API in the future such that we can try