coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

du: Avoid unnecessary call to GetFileInformationByHandleEx

Open jesseschalken opened this issue 1 year ago • 9 comments

We don't need to call GetFileInformationByHandleEx to track blocks if --apparent-size was passed.

This removes blocks from Stat and instead moves the handling of --apparent-size into Stat::new so it can avoid calling GetFileInformationByHandleEx if necessary.

~1.65x speed up on my test folder.

Before

> cargo build --release
> measure-command { .\target\release\coreutils.exe du --apparent-size "test folder" }
TotalSeconds      : 11.5132039

After

> cargo build --release
> measure-command { .\target\release\coreutils.exe du --apparent-size "test folder" }
TotalSeconds      : 6.955348

jesseschalken avatar Nov 03 '24 06:11 jesseschalken

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Nov 03 '24 14:11 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/rm/rm1 (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Nov 11 '24 21:11 github-actions[bot]

some tests fails:

--- TRY 3 STDOUT:        coreutils::tests test_du::test_du_basics ---

running 1 test
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe du
test test_du::test_du_basics ... FAILED

failures:

failures:
    test_du::test_du_basics

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2806 filtered out; finished in 0.17s


--- TRY 3 STDERR:        coreutils::tests test_du::test_du_basics ---
thread 'test_du::test_du_basics' panicked at tests\by-util\test_du.rs:63:5:
assertion `left == right` failed
  left: "1\t.\\subdir\\deeper\\deeper_dir\n1\t.\\subdir\\deeper\n9\t.\\subdir\\links\n9\t.\\subdir\n9\t.\n"
 right: "0\t.\\subdir\\deeper\\deeper_dir\n0\t.\\subdir\\deeper\n8\t.\\subdir\\links\n8\t.\\subdir\n8\t.\n"
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:662
   1: core::panicking::panic_fmt
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:74
   2: core::panicking::assert_failed_inner
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:412
   3: core::panicking::assert_failed<ref$<str$>,ref$<str$> >
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library\core\src\panicking.rs:367
   4: tests::test_du::_du_basics
             at .\tests\by-util\test_du.rs:63
   5: tests::test_du::test_du_basics
             at .\tests\by-util\test_du.rs:39
   6: tests::test_du::test_du_basics::closure$0
             at .\tests\by-util\test_du.rs:26
   7: core::ops::function::FnOnce::call_once<tests::test_du::test_du_basics::closure_env$0,tuple$<> >
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library\core\src\ops\function.rs:250
   8: core::ops::function::FnOnce::call_once
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

  TRY 3 FAIL [   0.188s] coreutils::tests test_du::test_du_basics_subdir

sylvestre avatar Nov 11 '24 21:11 sylvestre

ping ?

sylvestre avatar Nov 14 '24 19:11 sylvestre

any update? thanks

sylvestre avatar Nov 28 '24 16:11 sylvestre

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Nov 28 '24 17:11 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Dec 02 '24 10:12 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Feb 14 '25 13:02 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Apr 17 '25 20:04 github-actions[bot]

please reopen when ready

sylvestre avatar Sep 09 '25 21:09 sylvestre