Skip to content

numfmt: improve performances - #14003

Merged
sylvestre merged 3 commits into
uutils:mainfrom
sylvestre:numfmt-perf
Aug 20, 2026
Merged

numfmt: improve performances#14003
sylvestre merged 3 commits into
uutils:mainfrom
sylvestre:numfmt-perf

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

No description provided.

Output went through the line-buffered stdout lock, so converting a stream cost
one write syscall per line: 200k lines spent 107ms of the 275ms run in the
kernel. Buffer a block at a time when stdout is not a terminal, which is what
GNU gets from stdio, and keep line buffering on a terminal so output still
appears as it is produced. 275ms -> 165ms, with system time down to 4ms.
Rust's {:.0} is exact to the last digit and pays for it with a big-integer
expansion of the value: dragon::format_exact alone was 20% of the instructions
of a --to=si run. Almost everything numfmt prints is a whole number, and for
those the digits are just the integer, so round and print that instead, falling
back to the general formatter outside the range where an f64 holds every
integer. 165ms -> 101ms on 200k lines, against 136ms for GNU.
Copilot AI lite review requested due to automatic review settings August 18, 2026 15:47

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.

@sylvestre sylvestre changed the title Numfmt: improve performances numfmt: improve performances Aug 18, 2026
@xtqqczze

Copy link
Copy Markdown
Contributor

We could use zmij crate for fast floating point formatting?

@sylvestre

Copy link
Copy Markdown
Contributor Author

Maybe?

Copilot AI review requested due to automatic review settings August 19, 2026 14:18

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.

@codspeed-hq

codspeed-hq Bot commented Aug 20, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 8.44%

⚡ 9 improved benchmarks
✅ 124 untouched benchmarks
⏩ 274 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation numfmt_stream_to_si 414.1 ms 291.6 ms +42.01%
Simulation numfmt_from_si[10000] 83.3 ms 75.7 ms +10.09%
Simulation numfmt_stream_to_si_precision 346.4 ms 330.1 ms +4.93%
Simulation numfmt_to_si[10000] 90 ms 86.4 ms +4.11%
Simulation numfmt_round_modes[("up", 10000)] 90.9 ms 87.3 ms +4.06%
Simulation numfmt_padding[(10000, 50)] 95.8 ms 92.1 ms +4.01%
Simulation numfmt_round_modes[("towards-zero", 10000)] 91 ms 87.5 ms +3.97%
Simulation numfmt_round_modes[("down", 10000)] 91.3 ms 87.9 ms +3.95%
Simulation numfmt_large_numbers_si[10000] 96.7 ms 93.2 ms +3.83%

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:numfmt-perf (b239a3a) with main (b2a617e)2

Open in CodSpeed

Footnotes

  1. 274 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 (e275cd5) during the generation of this report, so b2a617e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@sylvestre
sylvestre merged commit 8fe6e9e into uutils:main Aug 20, 2026
127 of 169 checks passed
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.

3 participants