Skip to content

chore: remove MARF trie-node caching#7371

Open
cylewitruk-stacks wants to merge 4 commits into
stacks-network:developfrom
cylewitruk-stacks:chore/remove-marf-node-caches
Open

chore: remove MARF trie-node caching#7371
cylewitruk-stacks wants to merge 4 commits into
stacks-network:developfrom
cylewitruk-stacks:chore/remove-marf-node-caches

Conversation

@cylewitruk-stacks

@cylewitruk-stacks cylewitruk-stacks commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Removes the unused trie node cache (which is always defaulted as "noop" today) and related tests.

This was previously agreed within the team -- prioritizing now as the removal of the unnecessary caching tests removes a number of long-running tests run both in CI and locally.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the (currently unused) MARF trie-node caching plumbing and updates the surrounding configuration, storage internals, and test harness to match, with the goal of reducing long-running test time in CI/local runs.

Changes:

  • Remove MARF trie-node cache strategy from MARFOpenOpts and from NodeConfig’s effective MARF options.
  • Replace the old cache implementation with a smaller BlockHashCache that only caches block-hash/block-ID lookups.
  • Update MARF-related tests and docs to use the new MARFOpenOpts::new(hash_mode, external_blobs) API and new test option templates.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
stackslib/src/config/mod.rs Removes marf_cache_strategy from runtime node config and MARF opts; keeps config-file field with deprecation warning.
stackslib/src/clarity_vm/tests/ephemeral.rs Updates ephemeral MARF initialization to new MARFOpenOpts::new signature.
stackslib/src/clarity_vm/database/marf.rs Updates in-memory MARF open options to new API.
stackslib/src/chainstate/stacks/index/test/trie.rs Switches tests to updated rstest template (tpl_all_opts).
stackslib/src/chainstate/stacks/index/test/squash.rs Updates squash tests to new MARFOpenOpts::new signature.
stackslib/src/chainstate/stacks/index/test/mod.rs Removes cache-test module and simplifies MARF option matrices/templates.
stackslib/src/chainstate/stacks/index/test/marf.rs Updates loops over MARF options to the new ALL_OPTS.
stackslib/src/chainstate/stacks/index/test/marf_regression.rs Removes cache-strategy dimension from regression naming/coverage.
stackslib/src/chainstate/stacks/index/test/marf_perfs.rs Updates perf tests to iterate updated MARF option list; log formatting cleanup.
stackslib/src/chainstate/stacks/index/test/file.rs Updates file storage tests to new MARFOpenOpts::new signature.
stackslib/src/chainstate/stacks/index/storage.rs Removes node/hash caching code paths; uses BlockHashCache for block-hash/block-ID caching only.
stackslib/src/chainstate/stacks/index/squash.rs Updates squash open options to new MARF opts API.
stackslib/src/chainstate/stacks/index/marf.rs Removes cache strategy field from MARFOpenOpts and updates call sites.
stackslib/src/chainstate/stacks/index/cache.rs Replaces trie-node cache implementation with BlockHashCache.
stackslib/src/chainstate/stacks/db/snapshot/tests/clarity.rs Updates snapshot squash/open calls to new MARFOpenOpts::new signature.
stackslib/src/chainstate/stacks/db/snapshot/fork_storage.rs Updates readonly MARF open options to new signature.
stackslib/src/chainstate/stacks/db/snapshot/clarity.rs Updates clarity readonly MARF open options to new signature.
docs/profiling.md Updates debug-log example for config printing (needs follow-up for accuracy).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/profiling.md Outdated
@coveralls

coveralls commented Jul 1, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28520872114

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.3%) to 86.015%

Details

  • Coverage increased (+0.3%) from the base build.
  • Patch coverage: 25 uncovered changes across 5 files (87 of 112 lines covered, 77.68%).
  • 9151 coverage regressions across 136 files.

Uncovered Changes

File Changed Covered %
stackslib/src/config/mod.rs 15 4 26.67%
stackslib/src/chainstate/stacks/index/storage.rs 20 13 65.0%
stackslib/src/chainstate/stacks/index/test/marf_perfs.rs 4 0 0.0%
stackslib/src/chainstate/stacks/index/test/marf.rs 11 9 81.82%
stackslib/src/chainstate/stacks/index/marf.rs 2 1 50.0%
Total (13 files) 112 87 77.68%

Coverage Regressions

9151 previously-covered lines in 136 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
stackslib/src/chainstate/stacks/db/blocks.rs 511 89.82%
stackslib/src/chainstate/burn/db/sortdb.rs 505 90.19%
stackslib/src/chainstate/nakamoto/mod.rs 443 84.54%
stackslib/src/config/mod.rs 420 69.04%
stackslib/src/net/mod.rs 309 78.05%
stackslib/src/chainstate/stacks/index/storage.rs 275 82.01%
clarity/src/vm/database/clarity_db.rs 268 82.11%
stackslib/src/chainstate/stacks/miner.rs 263 83.12%
stackslib/src/chainstate/stacks/db/transactions.rs 253 97.15%
stackslib/src/net/inv/epoch2x.rs 222 79.38%

Coverage Stats

Coverage Status
Relevant Lines: 226515
Covered Lines: 194838
Line Coverage: 86.02%
Coverage Strength: 19016064.84 hits per line

💛 - Coveralls

/// Instantiate the default strategy. This can be taken from the `STACKS_MARF_CACHE_STRATEGY`
/// environ, or failing that, it will use a no-op strategy.
pub fn default() -> TrieCache<T> {
if let Ok(strategy) = std::env::var("STACKS_MARF_CACHE_STRATEGY") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe we should add in the changelog fragment also the removal of the env var?

Ok(node_hash)
}
let node_hash = self.inner_read_persisted_node_hash(block_id, ptr)?;
self.bench.read_node_hash_finish(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that we don't have anymore the cache, maybe we can simplify read_node_hash_finish by removing the bool parameter (and the extra logic inside the function)

let (node_inst, node_hash) =
self.inner_read_patched_persisted_nodetype(id, clear_ptr, read_hash)?;

self.bench.read_nodetype_finish(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as per read_node_hash_finish, but seems like that parameter was dead code even before this change

/// The batch size is intentionally set above 10.000 to force batched insertion
/// and exercise the `eta` batching logic.
/// For all configurations, the resulting root hash must remain stable.
#[rstest]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a strong opinion, but maybe we can keep this one to test the 10k batched insertion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants