Closed rubdos closed 9 months ago
LGTM! Just curious: what brought you to this part of the code? 😄
LGTM! Just curious: what brought you to this part of the code? smile
I was refactoring Whisperfish to use UUID and PhoneNumber instead of two strings in the database model, and then I assumed that PhoneNumber would probably be represented terribly inefficiently, compared to our previous model. I was wrong, but then spotted this. Very much nerd sniped.
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
c25b37f
) 71.18% compared to head (1f46da5
) 71.81%. Report is 2 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Looks like it's about 10% slower on Zen 1, but there seems to be a lot of room for improving the parser performance anyway.
This is on my i5-5200U laptop:
parse/+1 520 878 2491 time: [1.0924 µs 1.1045 µs 1.1201 µs]
change: [-10.809% -7.0258% -3.1920%] (p = 0.00 < 0.05)
parse/+1-520-878-2491 time: [502.38 ns 508.15 ns 515.20 ns]
change: [-8.6393% -6.1105% -3.7750%] (p = 0.00 < 0.05)
@gferon what do you think, pull this in?
semver-checks doesn't complain, Gabriel said "LGTM", so I'm pulling it in :upside_down_face:
This reduces the stack size of a PhoneNumber from 576 to 512 bits, by compressing the zeroes prefix into the value of the NationalNumber. The external API stays the same, but we win a precious 8 bytes because of alignment. If you don't have Carriers or Extensions, this is all on the stack too. Pretty cool.
We might be able to win 16 bits in
Code
too, but that'll need more trickery that might make it slightly less Rusty.I got nerd sniped. Will spin up some benchmarks to make sure this is not too bad in terms of performance.