-
Notifications
You must be signed in to change notification settings - Fork 916
Lazy init valid hex array #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
Init of a 64k boolean array take a long time (>30ms P90) during Android app launch.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7809 +/- ##
=========================================
Coverage 90.18% 90.18%
- Complexity 7226 7228 +2
=========================================
Files 820 820
Lines 21790 21795 +5
Branches 2135 2136 +1
=========================================
+ Hits 19651 19656 +5
Misses 1468 1468
Partials 671 671 ☔ 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. |
Instead of lazy init the whole array, we lazy init each values.
Init of a 64k boolean array take a long time (>30ms P90) during Android app launch.