uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.82k stars 1.28k forks source link

du: Avoid unnecessary call to GetFileInformationByHandleEx #6841

Open jesseschalken opened 3 weeks ago

jesseschalken commented 3 weeks ago

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
github-actions[bot] commented 3 weeks ago

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
github-actions[bot] commented 2 weeks ago

GNU testsuite comparison:

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

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 commented 1 week ago

ping ?