-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.Issues that may be good for new contributors looking for work to do.
Milestone
Description
(Possibly related to #7000)
We were trying to read concurrently (on Linux, go 1.3) from the Reader provided by crypto/rand, but were seeing a lot of unexpected contention. Taking a look at the implementation, it appears to take a mutex around the entire call just in order to protect the initialization step: https://github.com/golang/go/blob/master/src/crypto/rand/rand_unix.go#L51
This seems unnecessarily broad, since the underlying Read call itself should be safe to do concurrently. It would seem better to replace the mutex with a sync.Once which would allow concurrent reads, and also provide a fast path with an atomic op once the initialization is complete.
Thoughts?
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.Issues that may be good for new contributors looking for work to do.