feat(core): increase memory holding state trie - #2501
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR increases default in-process memory settings related to state trie handling, primarily by raising the default cache budget and reallocating the cache split to give trie pruning (dirty trie) substantially more headroom.
Changes:
- Increase default
--cachefrom 1024MB to 3072MB. - Adjust default cache split percentages for database IO, trie clean cache, and trie pruning (GC).
- Increase
core.TriesInMemoryfrom 128 to 1024 (affects trie retention/commit behavior).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| core/blockchain.go | Raises TriesInMemory, changing how many historical tries are retained/used in commit/GC logic. |
| cmd/utils/flags.go | Raises default cache size and changes default cache split percentages for DB/trie clean/trie GC; updates needed to keep CLI help accurate. |
Suppressed comments (1)
cmd/utils/flags.go:320
- The
--cache-gcflag help text still states the default is 25% (full) / 0% (archive), but the defaultValuewas changed to 34. This makes the CLI documentation misleading for operators.
Aliases: []string{"cache.gc"},
Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)",
Value: 34,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| receiptsCacheLimit = 32 | ||
| maxFutureBlocks = 256 | ||
| maxTimeFutureBlocks = 30 | ||
| TriesInMemory = 128 | ||
| TriesInMemory = 1024 | ||
|
|
| Aliases: []string{"cache.trie"}, | ||
| Usage: "Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)", | ||
| Value: 15, | ||
| Value: 5, |
Proposed changes
increase memory holding state trie.
Memory increase from 1024MB to 3072MB.
As for purpose, only "cache memory allowance to use for trie pruning" is increased. Other purpose is kept the same memory.
Tested on a mainnet node with fast sync from scratch. Memory usage is only 10% of the server.
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that