-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
make normalize ticksPerWheel more stable and high-performance #6070
Conversation
n |= n >>> 4; | ||
n |= n >>> 8; | ||
n |= n >>> 16; | ||
return (n < 0) ? 1 : (n >= 1073741824) ? 1073741824 : n + 1; |
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.
Can you make 1073741824
an static constant with a descriptive name ?
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.
Also share it with other places in the code.
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.
And constant better written in the form "1 << 30".
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.
@mmaxiaolei could you please address my comment ?
@mmaxiaolei also please sign our icla and adjust commit message to match our template: http://netty.io/s/ilcla |
@mmaxiaolei Could you please share some numbers? And add tests? |
@mmaxiaolei @slandelle also I wonder if it really makes a lot of difference as this one is only called in the constructor anyway. |
I agree with @slandelle and @normanmaurer ... please demonstrate the value this provides via JMH benchmark. Thanks. |
IMO benchmark not necessary. This optimization used also in JDK, referring to book "Hacker's Delight" sec 3-2 "Rounding Up/Down to the Next Power of 2". |
I am closing this now as it seems like @mmaxiaolei is not interested in this anymore. Please reopen if still interested and address the comments |
make normalize ticksPerWheel more stable and high-performance