Reduce Go garbage collection aggressiveness#97
Merged
Conversation
Contributor
|
🤖 Claude Code Review Status: Complete Current Review: This PR makes a simple, well-justified performance optimization by reducing Go's garbage collection frequency. The change is:
The profiling data in the PR description shows meaningful GC overhead (45-50%) that this change addresses. Setting GOGC at the container level is a good approach since it applies globally to all services in the image without code changes. No issues found. |
5f338f6 to
bb65ecd
Compare
|
icellan
approved these changes
Nov 4, 2025
8 tasks
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.



Reduces garbage collection frequency by setting
GOGC=200, triggering GC when heap grows to 300% of previous live set (vs. default 200%). This reduces GC cycles by ~50% during high-throughput operations like block validation.From a subtreevalidation profile during teratestnet sync:
1.39s 10.40% runtime.scanobject (GC scanning heap)
2.60s 19.45% runtime.gcAssistAlloc (goroutines helping GC)
4.32s 32.31% runtime.mallocgc (allocation + GC triggering)
Total GC overhead: ~6-7s out of 13.37s (45-50%)
GOGC=200 is conservative and we can probably increase in the future and make it configurable for specific deployments that have more memory available.