Skip to content

Commit 8b01d37

Browse files
committed
add sustainable badger configs
1 parent a4484f5 commit 8b01d37

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/store/badger_options.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,25 @@ import (
66
badger4 "github.com/ipfs/go-ds-badger4"
77
)
88

9+
const (
10+
// DefaultBadgerBlockCacheSize bounds Badger's block cache off-heap usage.
11+
// This node is primarily append/sync-oriented, so prefer a conservative
12+
// default over maximizing read cache hit rate.
13+
DefaultBadgerBlockCacheSize int64 = 128 << 20 // 128 MiB
14+
// DefaultBadgerIndexCacheSize bounds Badger's table index and bloom filter
15+
// cache to avoid growth with chain length.
16+
DefaultBadgerIndexCacheSize int64 = 256 << 20 // 256 MiB
17+
)
18+
919
// BadgerOptions returns ev-node tuned Badger options for the node workload.
1020
// These defaults favor write throughput for append-heavy usage.
1121
func BadgerOptions() *badger4.Options {
1222
opts := badger4.DefaultOptions
1323

24+
// Bound Badger-owned caches explicitly instead of inheriting a large block
25+
// cache and an unbounded index cache from the upstream defaults.
26+
opts.Options = opts.WithBlockCacheSize(DefaultBadgerBlockCacheSize)
27+
opts.Options = opts.WithIndexCacheSize(DefaultBadgerIndexCacheSize)
1428
// Disable conflict detection to reduce write overhead; ev-node does not rely
1529
// on Badger's multi-writer conflict checks for correctness.
1630
opts.Options = opts.WithDetectConflicts(false)

0 commit comments

Comments
 (0)