Skip to content

Commit

Permalink
btcd: don't override explicitly set GOGC
Browse files Browse the repository at this point in the history
If GOGC env var is explicitly set, use it. Otherwise, set GC to 10% (default).
  • Loading branch information
anupcshan committed Feb 9, 2022
1 parent 4dc4ff7 commit d7c125f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions btcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,14 @@ func loadBlockDB() (database.DB, error) {
}

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 {
Expand Down

0 comments on commit d7c125f

Please sign in to comment.