From 3986702b97d3395d6283d2b62e2cc5c41f46e770 Mon Sep 17 00:00:00 2001 From: Anup Chenthamarakshan Date: Thu, 9 Dec 2021 20:57:11 -0800 Subject: [PATCH] btcd: don't override explicitly set GOGC If GOGC env var is explicitly set, use it. Otherwise, set GC to 10% (default). --- btcd.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/btcd.go b/btcd.go index 1d1784d5..aec55e06 100644 --- a/btcd.go +++ b/btcd.go @@ -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 {