Skip to content

du: warm OS page cache before timing in benchmarks - #13958

Open
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:du-bench-stability
Open

du: warm OS page cache before timing in benchmarks#13958
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:du-bench-stability

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

First iterations run cold (page cache empty) and subsequent ones hot, creating a bimodal distribution and spurious CI regression alerts. Add warm_cache() to run one untimed traversal before measurement starts.

First iterations run cold (page cache empty) and subsequent ones hot,
creating a bimodal distribution and spurious CI regression alerts.
Add warm_cache() to run one untimed traversal before measurement starts.
Copilot AI lite review requested due to automatic review settings August 15, 2026 09:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR stabilizes du benchmark results by warming the OS page/inode cache before timed measurements, reducing cold-vs-hot bimodal timing distributions that can trigger noisy CI regressions.

Changes:

  • Add a warm_cache() helper that runs one untimed du traversal prior to benchmarking.
  • Invoke warm_cache() in each benchmark after generating the filesystem tree.
  • Minor import/order and doc-comment punctuation updates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +62 to +65
/// Run a throwaway traversal to warm the OS page/inode cache before timing.
fn warm_cache(path: &std::path::Path) {
let _ = black_box(uumain(get_bench_args(&[&path]).into_iter()));
}
Comment on lines 82 to 90
fn du_all_wide_tree(bencher: Bencher, (total_files, total_dirs): (usize, usize)) {
let temp_dir = TempDir::new().unwrap();
let temp_path = temp_dir.path();
fs_tree::create_wide_tree(temp_path, total_files, total_dirs);
warm_cache(temp_path);

bencher
.with_inputs(|| get_bench_args(&[&"-a", &temp_path]).into_iter())
.bench_values(|args| black_box(uumain(args)));
/// Benchmark du on wide directory structures (many files/dirs, shallow)
/// Run a throwaway traversal to warm the OS page/inode cache before timing.
fn warm_cache(path: &std::path::Path) {
let _ = black_box(uumain(get_bench_args(&[&path]).into_iter()));
@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 149.11 MB (+112 KB, +0.07%)

Significant per-binary changes:
  [           1.10 MB ->    1.18 MB  (+76 KB, +6.74%)
  mkfifo      1.09 MB ->    1.16 MB  (+76 KB, +6.81%)
  test        1.10 MB ->    1.18 MB  (+76 KB, +6.74%)
  install     1.25 MB ->    1.32 MB  (+72 KB, +5.62%)
  mkdir       1.10 MB ->    1.17 MB  (+72 KB, +6.38%)
  mknod       1.10 MB ->    1.17 MB  (+72 KB, +6.41%)
  chmod       1.15 MB ->    1.22 MB  (+68 KB, +5.76%)

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)

@codspeed-hq

codspeed-hq Bot commented Aug 15, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 13.15%

⚡ 1 improved benchmark
✅ 352 untouched benchmarks
⏩ 50 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory du_summarize_balanced_tree[(5, 4, 10)] 476.2 KB 420.9 KB +13.15%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing sylvestre:du-bench-stability (013f732) with main (b7a7b40)

Open in CodSpeed

Footnotes

  1. 50 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants