Skip to content

numfmt: add grouping and debug options with locale support#10506

Closed
mattsu2020 wants to merge 7 commits intouutils:mainfrom
mattsu2020:numfmt.pl
Closed

numfmt: add grouping and debug options with locale support#10506
mattsu2020 wants to merge 7 commits intouutils:mainfrom
mattsu2020:numfmt.pl

Conversation

@mattsu2020
Copy link
Contributor

@mattsu2020 mattsu2020 commented Jan 27, 2026

  • Add --grouping option to use locale-specific separators in output
  • Add libc dependency for locale handling
  • Update help and error messages for new options
  • Add validation to prevent combining grouping with format
  • Include translations for new options in en-US and fr-FR locales

related
tests/numfmt/numfmt.pl

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)

@mattsu2020 mattsu2020 marked this pull request as draft January 27, 2026 11:24
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 27, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 65.44%

Comparing mattsu2020:numfmt.pl (da05f38) with main (cd96d3b)

Summary

❌ 18 regressed benchmarks
✅ 266 untouched benchmarks
⏩ 38 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory numfmt_large_numbers_si[10000] 4 MB 4.3 MB -6.81%
Memory numfmt_round_modes[("towards-zero", 10000)] 3.9 MB 4.2 MB -6.37%
Memory numfmt_round_modes[("up", 10000)] 3.9 MB 4.2 MB -6.37%
Memory numfmt_padding[(10000, 50)] 3.9 MB 4.2 MB -6.37%
Memory numfmt_to_si_precision[10000] 3.9 MB 4.2 MB -6.37%
Memory numfmt_round_modes[("down", 10000)] 3.9 MB 4.2 MB -6.37%
Memory numfmt_to_iec[10000] 3.9 MB 4.2 MB -6.37%
Memory numfmt_to_si[10000] 3.9 MB 4.2 MB -6.37%
Memory numfmt_from_si[10000] 3.9 MB 4.2 MB -6.54%
Simulation numfmt_round_modes[("up", 10000)] 36.3 ms 101.7 ms -64.33%
Simulation numfmt_to_si_precision[10000] 37.4 ms 103.3 ms -63.77%
Simulation numfmt_to_iec[10000] 35.7 ms 103.2 ms -65.44%
Simulation numfmt_large_numbers_si[10000] 38.3 ms 105.2 ms -63.53%
Simulation numfmt_padding[(10000, 50)] 50 ms 106.7 ms -53.17%
Simulation numfmt_to_si[10000] 35.6 ms 101.3 ms -64.89%
Simulation numfmt_from_si[10000] 34.2 ms 95.3 ms -64.16%
Simulation numfmt_round_modes[("down", 10000)] 36.3 ms 101.8 ms -64.34%
Simulation numfmt_round_modes[("towards-zero", 10000)] 36.3 ms 102.4 ms -64.52%

Footnotes

  1. 38 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.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/shuf/shuf-reservoir (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/sort/sort-stale-thread-mem (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)

@sylvestre
Copy link
Contributor

Once again, please split your pr into several small PR ...

@mattsu2020 mattsu2020 changed the title feat(numfmt): add grouping and debug options with locale support numfmt: add grouping and debug options with locale support Jan 27, 2026
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/shuf/shuf-reservoir (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/sort/sort-stale-thread-mem (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/numfmt/numfmt is no longer failing!

@ChrisDryden
Copy link
Collaborator

This PR was just merged that adds the debug flag and functionality for all of the debug details except for the grouping. When rebased it should make this PR much smaller: #10110

- Add `--grouping` option to use locale-specific separators in output
- Add `--debug` option to print warnings during processing
- Add `libc` dependency for locale handling
- Update help and error messages for new options
- Add validation to prevent combining grouping with format
- Include translations for new options in en-US and fr-FR locales
- Conditionally compile locale-related functions for non-Windows platforms
- Add Windows-specific stub implementations for `init_locale`, `locale_decimal_separator_char`, and `locale_grouping_separator_string`
- Mark test helper functions with `#[cfg(test)]` to avoid unused code warnings
- Simplify error handling using `let Some` and `let Ok` patterns
- Replace unsafe C string literal with safer `c""` macro
…rging

- Extracted `format_field_parse_error` function to centralize error message formatting
- Improved `merge_ranges` function with more efficient algorithm using iterator pattern
- Fixed logic bug where grouping validation was checking wrong condition
- Added early return for empty ranges in merge_ranges for better performance
- Simplified error handling in parse_field_list by using the new helper function
This commit introduces comprehensive support for handling large numbers and decimal precision in the numfmt utility. Key changes include:

- Added num-bigint and num-traits dependencies for arbitrary precision arithmetic
- Implemented DecimalValue struct for precise decimal number representation
- Added new error messages for value overflow scenarios
…pplied

Added checks for `from_unit` and `to_unit` being 1 to ensure `use_raw` is correctly set when no unit conversion or formatting is applied, fixing potential formatting issues in numfmt.
- Replace deprecated `std::iter::repeat().take()` with `std::iter::repeat_n()` for better performance
- Remove unnecessary `is_c_locale()` function that was Windows-specific
- Simplify field parsing logic by using `map_or()` instead of `map().unwrap_or()`
@sylvestre
Copy link
Contributor

it is still a huge pr and really sorry but i am tired of repeating the same thing to you :(

please split it

@sylvestre sylvestre closed this Feb 3, 2026
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/shuf/shuf-reservoir (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/sort/sort-stale-thread-mem (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)

@mattsu2020 mattsu2020 deleted the numfmt.pl branch February 4, 2026 01:33
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

Comments