-
Notifications
You must be signed in to change notification settings - Fork 923
Limit init valid hex array to range that can be true #7809
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7809 +/- ##
============================================
- Coverage 90.18% 90.11% -0.07%
- Complexity 7226 7324 +98
============================================
Files 820 825 +5
Lines 21790 22051 +261
Branches 2135 2179 +44
============================================
+ Hits 19651 19871 +220
- Misses 1468 1502 +34
- Partials 671 678 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| /** Returns whether the given {@code char} is a valid hex character. */ | ||
| public static boolean isValidBase16Character(char b) { | ||
| return VALID_HEX[b]; | ||
| if (validHex == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reading the volatile is going to make things slower
if we accept that multiple threads initialize the field, we can avoid this, see https://stackoverflow.com/questions/11051863/lazy-initialization-without-synchronization-or-volatile-keyword
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reading the volatile is going to make things slower
if we accept that multiple threads initialize the field, we can avoid this, see https://stackoverflow.com/questions/11051863/lazy-initialization-without-synchronization-or-volatile-keyword
OK. Let me look into that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you found a good solution that doesn't need locking 😄
|
@baolongnt we can't accept this unless you sign the CLA. Are you able to do so? |
Thanks for looking at the PR. I did not think it will get any eyes till I mark as ready. I will have the CLA signed by then. |
Init of a 64k boolean array take a long time (>30ms P90) during Android app launch.
Instead of lazy init the whole array, we lazy init each values.
275870d to
5e93095
Compare
|
@jkwatson @zeitlinger PR is ready. CLA signed. Thanks in advance for the review. @ |
|
Have you thought about just initializing the Something like this, since the array will have |
I did not think about it but I am happy to switch to that. It's def a simpler change so more practical. |
If you could give it a try and see how the startup time is on Android, I think I'd prefer the smaller, simpler change. |
Use the fact that the default initial boolean value is false
and only explicitly init the values between the extreme HEX values
This minimized impact during process startup esp. on mobile
as init of a 64k boolean array take a long time (>30ms P90) during Android app launch.