why semTabSize is 251?

72 views
Skip to first unread message

xie cui

unread,
Sep 15, 2021, 11:28:27 AM9/15/21
to golang-nuts
https://github.com/golang/go/blob/master/src/runtime/sema.go#L47 
why this const is 251, not other like 256?

Kurtis Rader

unread,
Sep 15, 2021, 12:43:18 PM9/15/21
to xie cui, golang-nuts
On Wed, Sep 15, 2021 at 8:28 AM xie cui <cuiw...@gmail.com> wrote:
https://github.com/golang/go/blob/master/src/runtime/sema.go#L47 
why this const is 251, not other like 256?

It's explained by the comment above that line:

// Prime to not correlate with any user patterns.

The value sizes a simple hash table. Making the number of elements a prime number allows using a simple hashing function with an acceptable probability of unwanted collisions. 

--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
Reply all
Reply to author
Forward
0 new messages