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

runtime: hashmap iterator start position not random enough #8688

Closed
rsc opened this Issue Sep 9, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@rsc
Contributor

rsc commented Sep 9, 2014

Just got with all.bash at tip:

# GOMAXPROCS=2 runtime -cpu=1,2,4
--- FAIL: TestMapIterOrder-2 (0.00s)
    map_test.go:437: Map with n=9 elements had consistent iteration order: [0 1 2 3 4 5 6 7 8]
FAIL
FAIL    runtime 19.833s

To reproduce:
    go test -run MapIterOrder -cpu=$(perl -e 'print "1,"x300') -v
always fails at least once.

The hash function is picking the same hash bit for all 9 values (1 in 512 chance). Then
instead of having two buckets we'd have one bucket plus an overflow bucket.

Right now the iterator either picks a random bucket or picks a random offset within a
single bucket.
I think it should do both: pick a random bucket and pick a random offset, and start at
that offset (and wrap) in every bucket.
@gopherbot

This comment has been minimized.

Show comment
Hide comment
@gopherbot

gopherbot Sep 9, 2014

Comment 1:

CL https://golang.org/cl/135660043 mentions this issue.

gopherbot commented Sep 9, 2014

Comment 1:

CL https://golang.org/cl/135660043 mentions this issue.
@randall77

This comment has been minimized.

Show comment
Hide comment
@randall77

randall77 Sep 9, 2014

Contributor

Comment 2:

This issue was closed by revision 251daf8.

Status changed to Fixed.

Contributor

randall77 commented Sep 9, 2014

Comment 2:

This issue was closed by revision 251daf8.

Status changed to Fixed.

@rsc rsc added fixed labels Sep 9, 2014

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015

@rsc rsc removed the release-go1.4 label Apr 14, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

wheatman added a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018

runtime: map iterators: always use intrabucket randomess
Fixes #8688

LGTM=rsc
R=golang-codereviews, bradfitz, rsc, khr
CC=golang-codereviews
https://golang.org/cl/135660043

wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018

runtime: map iterators: always use intrabucket randomess
Fixes #8688

LGTM=rsc
R=golang-codereviews, bradfitz, rsc, khr
CC=golang-codereviews
https://golang.org/cl/135660043

wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 30, 2018

runtime: map iterators: always use intrabucket randomess
Fixes #8688

LGTM=rsc
R=golang-codereviews, bradfitz, rsc, khr
CC=golang-codereviews
https://golang.org/cl/135660043

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.