File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
1121func 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 )
You can’t perform that action at this time.
0 commit comments