Skip to content

Commit 4b06872

Browse files
committed
fix(cache): reduce tx cache retention (#3299)
1 parent 326c729 commit 4b06872

3 files changed

Lines changed: 4 additions & 29 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Changes
1313

1414
- Optimization of mutex usage in cache for reaper [#3286](https://github.com/evstack/ev-node/pull/3286)
15+
- Reduce tx cache retention to avoid OOM under (really) heavy tx load [#3299](https://github.com/evstack/ev-node/pull/3299)
1516

1617
## v1.1.1
1718

block/internal/cache/manager.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,8 @@ const (
2525
// DataDAIncludedPrefix is the store key prefix for data DA inclusion tracking.
2626
DataDAIncludedPrefix = "cache/data-da-included/"
2727

28-
// DefaultTxCacheRetention is how long tx hashes stay in the
29-
// seen-tx cache before CleanupOldTxs evicts them.
30-
//
31-
// HACK(fiber-throughput): dropped from 24h to 30s while we chase
32-
// throughput, but the previous default was itself wrong: 24h is
33-
// retention × tps in memory, so any rollup with meaningful TPS
34-
// would OOM (we hit ~16 GB in under a minute at ~1.5M tx/s).
35-
// What this should be properly:
36-
// - Bounded by entry count, not wall time. The dedup window
37-
// should be "the last N txs we saw", LRU-evicted, so cache
38-
// memory is fixed regardless of throughput.
39-
// - Or expressed in DA blocks: "drop hashes once their txs
40-
// would have been retried out of the mempool", which is a
41-
// property of mempool TTL × DA block time, not 24 hours.
42-
// - 30s is a fine measurement default and a reasonable upper
43-
// bound for pretty much any rollup; pick the right number
44-
// when the cache structure itself is reworked.
28+
// DefaultTxCacheRetention is the default time to keep transaction hashes in cache.
29+
// Keeping a too high value can lead to OOM during heavy transaction load.
4530
DefaultTxCacheRetention = 30 * time.Second
4631
)
4732

block/internal/reaping/reaper.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,7 @@ const (
2424

2525
// CleanupInterval is how often the reaper sweeps expired hashes
2626
// out of the seen-tx cache.
27-
//
28-
// HACK(fiber-throughput): dropped from 1h to 5s. The original
29-
// 1h was effectively coupled to the previous 24h retention —
30-
// sweeping every hour against a 24h window means a cache entry
31-
// can outlive its retention by 1h, which is fine when retention
32-
// is a day but completely breaks at 30s retention (entries
33-
// would survive 12× past expiry). Whatever the right retention
34-
// turns out to be (see DefaultTxCacheRetention's note in
35-
// cache/manager.go), this value should be a small fraction of
36-
// it — not a fixed time. Better to derive: e.g.
37-
// retention/10 with a sane min/max.
38-
CleanupInterval = 5 * time.Second
27+
CleanupInterval = max(cache.DefaultTxCacheRetention/10, 5*time.Second)
3928
)
4029

4130
// Reaper is responsible for periodically retrieving transactions from the executor,

0 commit comments

Comments
 (0)