Skip to content

Commit 18c99b6

Browse files
authored
[turbopack] Only send the filesystem caching timing messages for slow events (#84646)
These are not very actionable for end users, but if they take more than 10s it might be a useful clue about system performance.
1 parent 714a702 commit 18c99b6

File tree

2 files changed

+19
-7
lines changed
  • turbopack/crates/turbo-tasks-backend/src

2 files changed

+19
-7
lines changed

turbopack/crates/turbo-tasks-backend/src/backend/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,10 +1184,13 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
11841184

11851185
if new_items {
11861186
let elapsed = start.elapsed();
1187-
turbo_tasks().send_compilation_event(Arc::new(TimingEvent::new(
1188-
"Finished writing to filesystem cache".to_string(),
1189-
elapsed,
1190-
)));
1187+
// avoid spamming the event queue with information about fast operations
1188+
if elapsed > Duration::from_secs(10) {
1189+
turbo_tasks().send_compilation_event(Arc::new(TimingEvent::new(
1190+
"Finished writing to filesystem cache".to_string(),
1191+
elapsed,
1192+
)));
1193+
}
11911194
}
11921195

11931196
Some((snapshot_time, new_items))

turbopack/crates/turbo-tasks-backend/src/database/turbo/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
use std::{cmp::max, path::PathBuf, sync::Arc, thread::available_parallelism, time::Instant};
1+
use std::{
2+
cmp::max,
3+
path::PathBuf,
4+
sync::Arc,
5+
thread::available_parallelism,
6+
time::{Duration, Instant},
7+
};
28

39
use anyhow::{Ok, Result};
410
use parking_lot::Mutex;
@@ -135,8 +141,11 @@ fn do_compact(
135141
})?;
136142
if ran {
137143
let elapsed = start.elapsed();
138-
turbo_tasks()
139-
.send_compilation_event(Arc::new(TimingEvent::new(message.to_string(), elapsed)));
144+
// avoid spamming the event queue with information about fast operations
145+
if elapsed > Duration::from_secs(10) {
146+
turbo_tasks()
147+
.send_compilation_event(Arc::new(TimingEvent::new(message.to_string(), elapsed)));
148+
}
140149
}
141150
Ok(())
142151
}

0 commit comments

Comments
 (0)