-
Notifications
You must be signed in to change notification settings - Fork 336
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
Gops hangs if there are too many Go processes to examine #123
Comments
This is impacting me as well. Was able to get around it temporarily by upping the magic number to 100 without a problem, though that's obviously not the right fix. |
@siebenmann @dbraley could you please check if this PR fixes this issue. |
Purely on inspection I believe that this will fix the issue I'm experiencing, however I believe it will also reintroduce issue #118. Since |
@siebenmann thanks for the insight. I have modified the code to use wg instead of limitCh. |
The change introduced above (see #125) moves the whole for-loop into a go routine (also suggested in the issue description). Ignoring the whitespace changes ( |
It seems to me the simplest fix would be to make |
I personally prefer to avoid buffered channels, but yeah -- it's possible as well. |
Actually, did not initially notice that |
But by that point, receiving from |
But reading from |
I see now. Using len(pss) would work. |
@josharian I've refactored my cl and made it testable. |
@josharian Added a fix-123-buffered branch. Please take a look and feel free to try it out yourself. |
Oups, sorry, forgot to push the changes. Now it's there. |
Also added a version, which creates less go-routines, and doesn't use buffered channels. Please take a look https://github.com/yarcat/gops/blob/fix-123-no-buffers/goprocess/gp.go (the branch is still based on a PR #125) |
Limit the number of concurrent workers by starting a fixed number of goroutines and providing work by an input channel. Fixes google#123
Limit the number of concurrent workers by starting a fixed number of goroutines and providing work by an input channel. Fixes #123
The tests verify google#123 fix and prevent future regressions.
The test verifies that #123 is fixed and prevents future regressions.
Sorry for the delay! Can confirm this fixed the problem for me as well, thanks @rakyll, @yarcat, @mseshachalam, |
If you have more than ten (I believe) Go processes, gops will hang in goprocess/gp.go's FindAll() function. This happens because the 'for .. range pss { ...}' loop attempts to obtain a limitCh token before starting the goroutine, but the goroutines only release their token after they have sent their reply to the
found
channel. Since thefound
channel is unbuffered and is only read from by the main code after the 'for .. range pss {}' loop finishes, this deadlocks if the number of goroutines would ever be limited.I think either the entire 'for .. range pss { ... }' loop needs to be in a goroutine so that it doesn't block reading from the
found
channel, or thelimitCh
token must be released by the code before sending tofound
. The former change seems easier and I think it's correct.The text was updated successfully, but these errors were encountered: