diff --git a/btcd.go b/btcd.go index e1fdf04b..10b2a957 100644 --- a/btcd.go +++ b/btcd.go @@ -11,6 +11,7 @@ import ( _ "net/http/pprof" "os" "runtime" + "runtime/debug" "runtime/pprof" "github.com/btcsuite/btcd/blockchain/indexers" @@ -150,6 +151,12 @@ func main() { // Use all processor cores. runtime.GOMAXPROCS(runtime.NumCPU()) + // 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 { fmt.Fprintf(os.Stderr, "failed to set limits: %v\n", err)