main: Limit garbage collection percentage. (#686)

This reduces the target ratio of freshly allocated data to live data to
10% in order to limit excessive overallocations by the garbage collector
during data bursts such as processing complex blocks or rapidly
receiving a lot of large transactions.
This commit is contained in:
Dave Collins 2016-05-05 14:16:58 -05:00
parent 1a0e7452f3
commit 128366734f

View File

@ -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)