-
Notifications
You must be signed in to change notification settings - Fork 18k
x/time/rate: Wait can be slow to allow events #37058
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
Comments
I can reproduce on Linux. Both 1.13.7 and tip. I can not reproduce on Darwin - that can do ~96K/sec. Increasing the burst size fixes this on Linux. Using 10 instead of 1 fixes the problem. Not sure what the underlying problem is. Timer quantization, perhaps? |
limiter.Wait(ctx) will call time.NewTimer() if need to wait. env: go version go1.14 linux/amd64
As @randall77 said: increasing the burst size can fixes the problem. That's because increasing the burst size will reduce to call time.NewTimer(). |
I think this can be folded into #47084 which has a bit more investigation. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I use rate limiter from standard library in order to limit the number of cycles of a some operation. The actual RPS is printed every second.
What did you expect to see?
Expected that the actual RPS would be about 100000, but in fact it's only about 26000. Also the CPU is underloaded (CPU usage is around 60-70% on my hardware, so it doesn't even consume a single core).
What did you see instead?
The text was updated successfully, but these errors were encountered: