Skip to content

perf: special case small integers in fmt#500

Merged
prestwich merged 1 commit intorecmo:mainfrom
DaniPopes:perf-fmt-minor
Jul 22, 2025
Merged

perf: special case small integers in fmt#500
prestwich merged 1 commit intorecmo:mainfrom
DaniPopes:perf-fmt-minor

Conversation

@DaniPopes
Copy link
Contributor

@DaniPopes DaniPopes commented Jul 19, 2025

This is a very cheap check to avoid using to_base_be at all when the integer is small enough. It doesn't show any improvements in the benchmarks for >128 bits because the numbers are uniformly sampled, so they will always be at full bits, but it's a massive speed up as can be seen from the 64 and 128 bit benchmarks.

Based on #490.

@DaniPopes DaniPopes changed the title Perf fmt minor perf: improve fmt some more Jul 19, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 19, 2025

CodSpeed Performance Report

Merging #500 will improve performances by ×2.3

Comparing DaniPopes:perf-fmt-minor (102e883) with main (2973b98)

Summary

⚡ 7 improvements
✅ 288 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
fmt/binary/64 4.2 ms 2.6 ms +59.02%
fmt/decimal/128 4.8 ms 2.3 ms ×2.1
fmt/decimal/64 2.8 ms 1.3 ms ×2.1
fmt/hex/128 5.3 ms 3 ms +76.58%
fmt/hex/64 3.5 ms 1.5 ms ×2.3
fmt/octal/128 4.9 ms 3.1 ms +59.58%
fmt/octal/64 2.9 ms 1.5 ms +99.5%

@DaniPopes DaniPopes force-pushed the perf-fmt-minor branch 4 times, most recently from ecebd71 to 5f30fa8 Compare July 19, 2025 20:45
@DaniPopes DaniPopes changed the title perf: improve fmt some more perf: special case small integers in fmt Jul 22, 2025
@DaniPopes DaniPopes marked this pull request as ready for review July 22, 2025 07:13
@DaniPopes DaniPopes requested a review from prestwich as a code owner July 22, 2025 07:13
@prestwich prestwich merged commit 802d14d into recmo:main Jul 22, 2025
19 checks passed
@DaniPopes DaniPopes deleted the perf-fmt-minor branch July 22, 2025 16:03
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