numfmt: improve performances - #14003
Open
sylvestre wants to merge 2 commits into
Open
Conversation
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.
Contributor
|
We could use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.