Skip to content

Commit dcc4adf

Browse files
gballetkaralabe
authored andcommitted
cmd/geth: wrong memory size sanitizing on OpenBSD (#19793)
1 parent d9c75cd commit dcc4adf

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cmd/geth/main.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"math"
2323
"os"
24+
"runtime"
2425
godebug "runtime/debug"
2526
"sort"
2627
"strconv"
@@ -256,11 +257,15 @@ func init() {
256257
}
257258
// Cap the cache allowance and tune the garbage collector
258259
var mem gosigar.Mem
259-
if err := mem.Get(); err == nil {
260-
allowance := int(mem.Total / 1024 / 1024 / 3)
261-
if cache := ctx.GlobalInt(utils.CacheFlag.Name); cache > allowance {
262-
log.Warn("Sanitizing cache to Go's GC limits", "provided", cache, "updated", allowance)
263-
ctx.GlobalSet(utils.CacheFlag.Name, strconv.Itoa(allowance))
260+
// Workaround until OpenBSD support lands into gosigar
261+
// Check https://github.com/elastic/gosigar#supported-platforms
262+
if runtime.GOOS != "openbsd" {
263+
if err := mem.Get(); err == nil {
264+
allowance := int(mem.Total / 1024 / 1024 / 3)
265+
if cache := ctx.GlobalInt(utils.CacheFlag.Name); cache > allowance {
266+
log.Warn("Sanitizing cache to Go's GC limits", "provided", cache, "updated", allowance)
267+
ctx.GlobalSet(utils.CacheFlag.Name, strconv.Itoa(allowance))
268+
}
264269
}
265270
}
266271
// Ensure Go's GC ignores the database cache for trigger percentage

trie/sync_bloom.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewSyncBloom(memory uint64, database ethdb.Iteratee) *SyncBloom {
7070
// Create the bloom filter to track known trie nodes
7171
bloom, err := bloomfilter.New(memory*1024*1024*8, 3)
7272
if err != nil {
73-
panic(fmt.Sprintf("failed to create bloom: %v", err)) // Can't happen, here for sanity
73+
panic(fmt.Sprintf("failed to create bloom: %v", err))
7474
}
7575
log.Info("Allocated fast sync bloom", "size", common.StorageSize(memory*1024*1024))
7676

0 commit comments

Comments
 (0)