Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

mmaxiaolei
Copy link

make normalize ticksPerWheel more stable and high-performance

n |= n >>> 4;
n |= n >>> 8;
n |= n >>> 16;
return (n < 0) ? 1 : (n >= 1073741824) ? 1073741824 : n + 1;
Copy link
Member

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 ?

Copy link
Member

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.

Copy link
Contributor

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".

Copy link
Member

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 ?

@normanmaurer
Copy link
Member

@mmaxiaolei also please sign our icla and adjust commit message to match our template:

http://netty.io/s/ilcla
http://netty.io/wiki/writing-a-commit-message.html

@slandelle
Copy link
Contributor

slandelle commented Nov 29, 2016

high-performance

@mmaxiaolei Could you please share some numbers? And add tests?

@normanmaurer
Copy link
Member

@mmaxiaolei @slandelle also I wonder if it really makes a lot of difference as this one is only called in the constructor anyway.

@Scottmitch
Copy link
Member

I agree with @slandelle and @normanmaurer ... please demonstrate the value this provides via JMH benchmark. Thanks.

@fenik17
Copy link
Contributor

fenik17 commented Dec 1, 2016

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".
For example look at ConcurrentHashMap.tableSizeFor().

@normanmaurer normanmaurer self-assigned this Dec 2, 2016
@normanmaurer
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants