-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fit NationalNumber in 64 bits #52
Conversation
LGTM! Just curious: what brought you to this part of the code? 😄 |
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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #52 +/- ##
==========================================
+ Coverage 71.18% 71.81% +0.63%
==========================================
Files 19 19
Lines 1933 1955 +22
==========================================
+ Hits 1376 1404 +28
+ Misses 557 551 -6 ☔ View full report in Codecov by Sentry. |
df8eb32
to
7d03bc9
Compare
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:
|
@gferon what do you think, pull this in? |
7d03bc9
to
f69abee
Compare
semver-checks doesn't complain, Gabriel said "LGTM", so I'm pulling it in 🙃 |
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.