Repository navigation
Fix goroutine and memory leaks in engine - #6760
Merged
Merged
Conversation
Turns out that the goroutine used to call cancel when the grpc hijack conn's closeCh is closed is just not necessary at all and can be removed. That closeCh is called when .Close is explicitly called, but in that case there's no need to cancel our context; the context will be cancelled anyways when the method returns. Signed-off-by: Erik Sipsma <[email protected]>
The defer used to log "handler done" could block forever in the case where the HandlerFunc never ends up actually being executed (i.e. some error or disconnection happens before it even gets invoked). This is because the chan we waited on was closed from within that HandlerFunc. The fix here just removes the chan entirely and moves the "handler done" log to the HandlerFunc itself, which is also much simpler anyways. Signed-off-by: Erik Sipsma <[email protected]>
vito
approved these changes
Feb 27, 2024
Contributor
|
Nice 🎉 Didn't get a chance to review this before merging, but LGTM 🎉 Also fixes #6604. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #6719
See individual commit messages for explanations.
Running the full
TestModulesuite locally now shows RSS maxing out around 1GB (still high-ish but much more reasonable than 6GB). And most importantly, whereas previously the engine's RSS stayed high after the test suite ended (it stuck around 2-3 GB RSS), now the RSS drops down to reasonable 600MB afterwards, withpprofshowing reasonable usage mostly from buildkit's in memory cache metadata:Also, previously there were 20000+ goroutines laying around after the test suite was done. Now there's only 21.