-
Notifications
You must be signed in to change notification settings - Fork 134
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
Fix worker random race condition #179
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, I'm just curious: what's the impact of this change on the benchmark of the original PR: #178 ?
92884bd
to
7584327
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -71,9 +73,15 @@ func (w *worker) processMetric(m metric) error { | |||
} | |||
|
|||
func (w *worker) shouldSample(rate float64) bool { | |||
// rand.NewSource is not thread safe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: for clarity, I suggest:
// rand.NewSource is not thread safe. | |
// sources created by rand.NewSource() (ie. w.random) are not thread safe. |
rand.NewSource
is not thread safe. Each worker needs its own random and random-lock.