Repository navigation
du: count subdirectories in --total with --separate-dirs, print time on total line - #15455
emirmrkaljevic wants to merge 2 commits into
Conversation
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
|
GNU testsuite comparison: |
| } | ||
| } | ||
|
|
||
| #[inline] |
There was a problem hiding this comment.
Was this not being inlined anyway? Non-public functions don't usually benefit from the #[inline] attribute.
There was a problem hiding this comment.
Good point, thanks! They weren't needed, so I removed both in cc0d2a2. I also checked the CodSpeed result locally: repeated du -a runs on a 5000/500 wide tree show no measurable wall-clock difference vs the base (about -0.2%, 95% CI -1.7% to +1.3%). The bench is mostly syscall time, which simulation mode doesn't count, so the 3.6% looks like noise to me, but happy to dig further if you see it differently.
There was a problem hiding this comment.
The CodSpeed result was likely noise, it has disappeared now.
|
@codspeedbot fix this regression |
|
|
||
| #[cfg(feature = "touch")] | ||
| #[test] | ||
| fn test_du_total_time_column() { |
There was a problem hiding this comment.
this test is very long, could you please split it (total time / atime-ctime / pre-1970)?
| )?; | ||
| if const { WITH_TOTAL } { | ||
| let time = if track_total_time { | ||
| match (saw_stat, grand_time) { |
There was a problem hiding this comment.
this seems complex, do we need saw_stat at all?
| // `--separate-dirs` left them out. Only then does each directory's | ||
| // own size have to be added back. Files stay inside their directory. | ||
| let count_separate_dirs = WITH_TOTAL && self.separate_dirs; | ||
| // GNU's total timestamp starts at the epoch and moves forward only, |
There was a problem hiding this comment.
please make this comment shorter, and describe the behavior, not how GNU does it internally (you must not read their code)
| } | ||
|
|
||
| fn print_stats(&self, rx: &mpsc::Receiver<UResult<StatPrintInfo>>) -> UResult<()> { | ||
| // Monomorphize so a run without `--total` does not track a total, |
There was a problem hiding this comment.
do we really need the const generic here? a plain if self.total would be much simpler
I fixed the regression in 44bc8f7 ( Cause. The Fix. I folded Local simulation results:
Callgrind confirms it: total instructions are within about 0.3% of Checks: If you want another look after CI runs, comment Summary
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot. |
| struct StatPrintInfo { | ||
| stat: Stat, | ||
| depth: usize, | ||
| /// Real directory bit for `--separate-dirs` with `--total`. |
There was a problem hiding this comment.
nobody will read such a long comment :) one line is enough
|
Thanks for the review, @sylvestre! Addressed in 329b250:
|
|
@emirmrkaljevic could you please rebase for a clean commit history |
329b250 to
b371d87
Compare
|
@xtqqczze rebased on main and squashed into a single commit. The du code is unchanged from the reviewed version; |
| let latest_time = options | ||
| .time | ||
| .and_then(|time| metadata_get_time(&metadata, time)); | ||
| let is_dir = metadata.is_dir(); |
There was a problem hiding this comment.
this local doesn't seem needed anymore, could you please revert this hunk?
|
Reverted that hunk in 30b7ffb, thanks! |
|
Binary size comparison: |
…on total line --separate-dirs was leaving subdirectory usage out of the grand total, and --time omitted the timestamp on that line. The total now adds every directory under --separate-dirs (file sizes stay in their parent, so -a does not count them twice), and with --time the total line shows the newest time seen, never moving back before 1970-01-01. The total time and subdirectory sizes are only tracked when --total is given, so other invocations keep the previous code path. Refs uutils#15254 Found with behave (https://github.com/emirmrkaljevic/behave). Co-authored-by: CodSpeed Bot <no-reply@codspeed.io>
30b7ffb to
939f1e7
Compare
Summary
du -cdropped subdirectory usage when-S/--separate-dirswas set, and it omitted the time column on thetotalline.The grand total now adds every directory under
--separate-dirs(file sizes stay in their parent, so-adoes not count them twice). With--time, the total line uses the same style and the newest atime, ctime, or mtime seen. A time before 1970 does not move that stamp backward from the epoch.Refs #15254
Test plan
cargo test --features "du touch" --no-default-features --test tests test_du_total— passcargo test --features "du touch chmod" --no-default-features --test tests test_du::— 118 passeddu --total --separate-dirsanddu --total --timeon the reported tree match GNU du 9.4 (28 ./36 total, and36 2024-03-01 18:00 total)Found with behave.