You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
go get github.com/jaffee/misc/schedmin
It first starts a goroutine which is making periodic HTTP requests, then sleeps for 4 seconds in order to allow a few requests to execute. It then generates and XORs random numbers together in a tight loop.
What did you expect to see?
On hardware with multiple cores, and GOMAXPROCS > 1, I expected the program to continue making HTTP requests for the duration of the work loop.
What did you see instead?
Shortly after the work loop starts, the HTTP loop hangs (typically on reading response body, though I've seen it happen at other places).
Periodically invoking runtime.Gosched() in the work loop allows the request loop to continue as expected.
This could be by design. The problem is specifically with goroutine preemption being blocked, not with inefficient use of computational resources by run-time.
I may be misunderstanding you, but I don't think this is an issue with goroutines not being pre-emptible. I have 8 cores, GOMAXPROCS=8, and I only have one goroutine running CPU bound code. Another goroutine which was started before the CPU bound code actually stops executing after the CPU bound code starts running.
It's my understanding that in this situation, the two goroutines should run in parallel since there are threads available for both of them.
What version of Go are you using (
go version
)?also 1.12.6 and 1.12.5
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputI have also reproduced this on linux_amd64 on a 32 core VM, and several coworkers have reproduced it on linux/mac.
What did you do?
Example:
https://play.golang.org/p/5rs3K751_md
You can also:
It first starts a goroutine which is making periodic HTTP requests, then sleeps for 4 seconds in order to allow a few requests to execute. It then generates and XORs random numbers together in a tight loop.
What did you expect to see?
On hardware with multiple cores, and GOMAXPROCS > 1, I expected the program to continue making HTTP requests for the duration of the work loop.
What did you see instead?
Shortly after the work loop starts, the HTTP loop hangs (typically on reading response body, though I've seen it happen at other places).
Periodically invoking runtime.Gosched() in the work loop allows the request loop to continue as expected.
I have a slightly more complex version of this example program which has flags for controlling various parameters at https://github.com/jaffee/misc/tree/master/schedissue/main.go
The text was updated successfully, but these errors were encountered: