Skip to content

numfmt: improve performances - #14003

Open
sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:numfmt-perf
Open

numfmt: improve performances#14003
sylvestre wants to merge 2 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?

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