Skip to content

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Oct 20, 2025

The fmt library removed fmt::detail::compute_width in version 12.0.0. Rather than using the new internal functions (for_each_codepoint and display_width_of), implement a simpler solution that avoids relying on fmt's internal API entirely.

The only multi-byte UTF-8 characters used in perf_tests output are:

  • ± (U+00B1, 2 bytes) in MAD percentages: " ±5.23%"
  • µ (U+00B5, 2 bytes) in microsecond units: "µs"

Both display as 1 column width despite being 2 bytes. The new apparent_width() function uses std::ranges::search to count occurrences of these specific byte subsequences and calculates the correct display width.

This approach is simpler, more maintainable, works with any fmt version, and doesn't depend on fmt's internal implementation details.

@tchaikov tchaikov changed the title perf_tests: Fix build with fmt 12.0.0 and add version-conditional wid… perf_tests: Fix build with fmt 12.0.0 Oct 20, 2025
@tchaikov
Copy link
Contributor Author

cc @travisdowns

@travisdowns
Copy link
Contributor

Thanks @tchaikov!

All these is just needed due to a the use of the ± character which is 2 bytes, when the "deviation" column is added. I was a bit reluctant to use the details method in the first place, and I see now it may have been a mistake: arguably it might be simpler just to hardcode special handling just for this 1 character. All other characters are highly likely to be ASCII as they are the test name and then numeric columns.

I didn't actually know we supported fmt 12 (tried recently to use this but had some compiler errors). Is this part of fmt 12 support?

@tchaikov
Copy link
Contributor Author

@travisdowns Hi Travis, you're absolutely right! I've updated the PR to use a simpler approach.

Instead of relying on fmt's internal detail namespace functions, the new implementation just handles the two specific multi-byte UTF-8 characters we actually use:

  • ± (U+00B1) in MAD percentages
  • µ (U+00B5) in microsecond units

Regarding fmt 12: it's not officially supported yet, but I'm working on compatibility since I develop on Arch Linux and Debian Sid which ship with fmt 12. This change (along with e5b1097 for another build issue) is part of that effort.

@tchaikov tchaikov force-pushed the fmt branch 2 times, most recently from 4aa9b12 to 7ea0603 Compare October 21, 2025 05:50
The fmt library removed fmt::detail::compute_width in version 12.0.0.
Rather than using the new internal functions (for_each_codepoint and
display_width_of), implement a simpler solution that avoids relying on
fmt's internal API entirely.

The only multi-byte UTF-8 characters used in perf_tests output are:
- ± (U+00B1, 2 bytes) in MAD percentages: " ±5.23%"
- µ (U+00B5, 2 bytes) in microsecond units: "µs"

Both display as 1 column width despite being 2 bytes. The new
apparent_width() function uses std::ranges::search to count occurrences
of these specific byte subsequences and calculates the correct display
width.

This approach is simpler, more maintainable, works with any fmt
version, and doesn't depend on fmt's internal implementation details.

Signed-off-by: Kefu Chai <[email protected]>
@travisdowns
Copy link
Contributor

µ (U+00B5) in microsecond units

Oh right, that was actually the original reason I had to add it (in the same series).

Thanks again for these fixes!

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.

2 participants