btcd: don't override explicitly set GOGC

If GOGC env var is explicitly set, use it. Otherwise, set GC to 10% (default).
This commit is contained in:
Anup Chenthamarakshan 2021-12-09 20:57:11 -08:00 committed by John C. Vernaleo
parent 85b6f7ed2a
commit 3986702b97

13
btcd.go
View file

@ -328,11 +328,14 @@ func init() {
}
func main() {
// Block and transaction processing can cause bursty allocations. This
// limits the garbage collector from excessively overallocating during
// bursts. This value was arrived at with the help of profiling live
// usage.
debug.SetGCPercent(10)
// If GOGC is not explicitly set, override GC percent.
if os.Getenv("GOGC") == "" {
// Block and transaction processing can cause bursty allocations. This
// limits the garbage collector from excessively overallocating during
// bursts. This value was arrived at with the help of profiling live
// usage.
debug.SetGCPercent(10)
}
// Up some limits.
if err := limits.SetLimits(); err != nil {