Skip to content

Comments

perf: optimize from_str_radix#557

Merged
prestwich merged 2 commits intorecmo:mainfrom
DaniPopes:dani/from-str-radix-perf
Feb 12, 2026
Merged

perf: optimize from_str_radix#557
prestwich merged 2 commits intorecmo:mainfrom
DaniPopes:dani/from-str-radix-perf

Conversation

@DaniPopes
Copy link
Contributor

@DaniPopes DaniPopes commented Feb 7, 2026

Use actual from_str routines instead of treating every character like a u64 digit.

@DaniPopes DaniPopes requested a review from prestwich as a code owner February 7, 2026 01:37
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 7, 2026

Merging this PR will improve performance by ×32

⚡ 59 improved benchmarks
✅ 327 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
most_significant_bits/4096/4096 29 µs 26.1 µs +11.19%
parse/binary/192/zero 598.8 µs 248.6 µs ×2.4
parse/binary/128/max 19.6 ms 7.6 ms ×2.6
parse/binary/256/max 51.7 ms 15.2 ms ×3.4
parse/binary/384/zero 875 µs 410.9 µs ×2.1
parse/binary/256/zero 679.8 µs 287.9 µs ×2.4
parse/binary/128/zero 559.6 µs 198.3 µs ×2.8
parse/binary/192/max 33.5 ms 11.4 ms ×2.9
parse/binary/512/zero 1,061.9 µs 511.6 µs ×2.1
parse/binary/384/max 104.1 ms 22.8 ms ×4.6
parse/binary/4096/max 77.9 ms 2.4 ms ×32
parse/binary/4096/zero 62.6 µs 32.3 µs +93.71%
parse/binary/512/max 171.4 ms 30.3 ms ×5.7
parse/decimal/192/max 10.4 ms 2.2 ms ×4.7
parse/binary/64/zero 467.5 µs 139.6 µs ×3.3
parse/binary/64/max 8.5 ms 3.3 ms ×2.6
parse/decimal/128/zero 559.6 µs 215.1 µs ×2.6
parse/decimal/256/zero 679.8 µs 340.8 µs +99.48%
parse/decimal/128/max 6.3 ms 1.6 ms ×3.9
parse/decimal/4096/max 23.5 ms 1.6 ms ×14
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing DaniPopes:dani/from-str-radix-perf (744ecc7) with main (bc691c1)

Open in CodSpeed

@DaniPopes DaniPopes force-pushed the dani/from-str-radix-perf branch 2 times, most recently from 767fd43 to 9d03973 Compare February 7, 2026 02:49
@DaniPopes DaniPopes force-pushed the dani/from-str-radix-perf branch from 9d03973 to 89f64de Compare February 7, 2026 02:50
@prestwich prestwich requested a review from gakonst February 12, 2026 00:06

65.. => Err(ParseError::InvalidRadix(radix)),
37.. => Self::from_str_radix_slow(src, radix),
r if r.is_power_of_two() => Self::from_str_radix_pow2(src, radix),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this case cover anything other than 4 and 32?

Copy link
Contributor Author

@DaniPopes DaniPopes Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ig not, should we remove it? i think it's fine

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it's fine. the perf gain from avoiding the function invocation for weird-power-of-2 bases seems ignorable

@prestwich prestwich merged commit fa46a21 into recmo:main Feb 12, 2026
19 checks passed
@DaniPopes DaniPopes deleted the dani/from-str-radix-perf branch February 12, 2026 00:26
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