This commit is contained in:
Eli Peter 2026-06-05 10:16:30 -05:00 committed by GitHub
parent 55247b7fcd
commit 991c84a1eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
1464 changed files with 225448 additions and 1985 deletions

View file

@ -235,16 +235,30 @@ fn module_graph_is_cheap() {
use std::time::Instant;
let r = root();
// Warm up: the first build pays cold filesystem-cache I/O (directory
// walk + file reads) which on a loaded CI runner can swamp the actual
// CPU cost we want to bound. Run once untimed to seed the page cache,
// and use this build for the RSS + packages assertions.
let bytes_before = approximate_rss_kib();
let start = Instant::now();
let graph = build_module_graph(std::slice::from_ref(&r));
let elapsed = start.elapsed();
let bytes_after = approximate_rss_kib();
// Time the steady-state cost as the best of several warm runs. Min,
// not a single sample, drops scheduler / disk jitter that would
// otherwise flake the ceiling on shared CI hosts.
let mut best = std::time::Duration::MAX;
for _ in 0..5 {
let start = Instant::now();
let g = build_module_graph(std::slice::from_ref(&r));
best = best.min(start.elapsed());
std::hint::black_box(&g);
}
assert!(
elapsed.as_millis() < 50,
"build_module_graph took {}ms (>50ms ceiling)",
elapsed.as_millis()
best.as_millis() < 50,
"build_module_graph took {}ms warm (>50ms ceiling)",
best.as_millis()
);
let delta_kib = bytes_after.saturating_sub(bytes_before);