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

user channel list 求余的问题 #56

Open
SongCF opened this issue Mar 13, 2017 · 1 comment
Open

user channel list 求余的问题 #56

SongCF opened this issue Mar 13, 2017 · 1 comment

Comments

@SongCF
Copy link

SongCF commented Mar 13, 2017

//func (l *ChannelList) Bucket(key string) *ChannelBucket 
idx := uint(h.Sum32()) & uint(Conf.ChannelBucket-1)  //其中 ChannelBucket = runtime.NumCPU()

只有当x=2^n(n为自然数)时,a % x = a & (x - 1 )才成立,
又服务器cpu至少我见过有10核12核的

那么这里就计算出的idx会有问题吧

@Terry-Mao
Copy link
Owner

我印象中,在配置文件里面有强制他2^n

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

No branches or pull requests

2 participants