Skip to content

du: support block-size suffixes and grouping - #13655

Merged
sylvestre merged 2 commits into
uutils:mainfrom
wtcpython:du-block-size-suffix
Nov 3, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
wtcpython:du-block-size-suffix

Conversation

@wtcpython

@wtcpython wtcpython commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #13605.

Preserve unit suffixes for block sizes specified without a numeric prefix, including values from DU_BLOCK_SIZE, BLOCK_SIZE, and BLOCKSIZE. Numeric block sizes keep their existing output format.

Should make test tests/du/block-size.sh pass

@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/du/block-size is no longer failing!

@codspeed

codspeed Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 8 untouched benchmarks
⏩ 464 skipped benchmarks1


Comparing wtcpython:du-block-size-suffix (b06672f) with main (8e267ce)2

Open in CodSpeed

Footnotes

  1. 464 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. ↩

  2. No successful run was found on main (e3627ff) during the generation of this report, so 8e267ce was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@wtcpython
wtcpython force-pushed the du-block-size-suffix branch 4 times, most recently from e32b9e0 to ed84080 Compare August 10, 2026 15:00
@wtcpython
wtcpython force-pushed the du-block-size-suffix branch from ed84080 to 3787179 Compare August 14, 2026 03:19
@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Binary size comparison:

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

Total size of compared binaries: 152.18 MB (+1004 KB, +0.65%)

Significant per-binary changes:
  comm     1.12 MB ->    2.33 MB  (+1.21 MB, +107.29%)

@wtcpython
wtcpython force-pushed the du-block-size-suffix branch from 3787179 to b0f102f Compare August 16, 2026 13:56
@wtcpython

Copy link
Copy Markdown
Contributor Author

Would you mind taking a look when convenient? Thanks!

@wtcpython
wtcpython force-pushed the du-block-size-suffix branch 2 times, most recently from c15bf43 to 5c139cf Compare August 24, 2026 11:32
@wtcpython
wtcpython force-pushed the du-block-size-suffix branch 3 times, most recently from 84baa46 to da537b5 Compare August 31, 2026 01:46
Copilot AI lite review requested due to automatic review settings September 14, 2026 06:46

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wtcpython

Copy link
Copy Markdown
Contributor Author

@sylvestre ready

Copilot AI review requested due to automatic review settings September 15, 2026 13:55

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 19, 2026 00:39

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 21, 2026 00:40

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI lite review requested due to automatic review settings October 4, 2026 01:16
@wtcpython
wtcpython force-pushed the du-block-size-suffix branch from a043220 to 69cae44 Compare October 4, 2026 01:16

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI lite review requested due to automatic review settings October 9, 2026 00:31
@wtcpython
wtcpython force-pushed the du-block-size-suffix branch from 69cae44 to f92c17c Compare October 9, 2026 00:31

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wtcpython
wtcpython force-pushed the du-block-size-suffix branch from f92c17c to dc98e1a Compare October 10, 2026 15:15
Copilot AI lite review requested due to automatic review settings October 10, 2026 15:15

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI lite review requested due to automatic review settings October 15, 2026 08:04
@wtcpython
wtcpython force-pushed the du-block-size-suffix branch from dc98e1a to 0bacf21 Compare October 15, 2026 08:04

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Copilot AI lite review requested due to automatic review settings October 21, 2026 01:39
@wtcpython
wtcpython force-pushed the du-block-size-suffix branch from 0bacf21 to 4cc9191 Compare October 21, 2026 01:39

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Comment thread src/uu/du/src/du.rs
Ok(bytes)
} else {
Ok(parse_block_size::default_block_size())
for var in vars {

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.

this duplicates parse_block_size::block_size_from_env, could you please extend it in uucore to also return the raw value instead? df/ls will need the same suffix handling

Comment thread src/uu/du/src/du.rs
}

let suffix = match chars.as_str() {
"" | "D" => unit.to_string(),

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.

which input ends up with a D suffix here? please add a test for it or drop it

Comment thread src/uu/du/src/du.rs
}

/// Add the locale grouping requested by a leading apostrophe in SIZE.
fn format_block_count(blocks: u64, grouping: bool) -> Vec<u8> {

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.

almost the same as apply_grouping in numfmt, could it be moved to uucore and shared?

Comment thread src/uu/du/src/du.rs
return digits.into_bytes();
}

let separator = if get_numeric_locale().1 == UEncoding::Ascii && separator == "\u{202f}" {

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.

why this special case for U+202F only?
please document the why, or handle it in uucore for all non-UTF-8 locales

Comment thread tests/by-util/test_du.rs
}

#[test]
fn test_du_block_size_locale_grouping() {

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.

this is probably the wasm failure, please add #[cfg_attr(wasi_runner, ignore = "WASI: locale env vars not propagated")] like the other locale tests

@sylvestre

Copy link
Copy Markdown
Contributor

sorry for the latency
it looks almost ready

@sylvestre
sylvestre force-pushed the du-block-size-suffix branch from 4cc9191 to b06672f Compare November 3, 2026 07:14
Copilot AI lite review requested due to automatic review settings November 3, 2026 07:14

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.

Comment thread src/uu/du/src/du.rs
Comment on lines +312 to +313
let parsed = s.strip_prefix('\'').unwrap_or(s);
parse_size_u64(parsed)
Comment thread src/uu/du/src/du.rs
Comment on lines +357 to +360
let suffix = match chars.as_str() {
"" | "D" => unit.to_string(),
"B" if unit == 'K' => "kB".to_string(),
suffix => format!("{unit}{suffix}"),
@sylvestre
sylvestre merged commit f1ae8f1 into uutils:main Nov 3, 2026
96 checks passed
@wtcpython
wtcpython deleted the du-block-size-suffix branch November 3, 2026 08:11
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.

du -BM behaves differently from GNU version

3 participants