Skip to content

Conversation

@jcnelson
Copy link
Member

@jcnelson jcnelson commented Nov 5, 2025

This PR implements work discovered in #6593. Specifically, it makes the following changes to the on-disk representation of the MARF:

  • If a TriePtr is not a back-block pointer, then the back_block field is not stored since it's always 0.

  • If a node's children TriePtr list is sparse, then instead of storing TriePtr::default() for empty pointers, the system now stores a bitmap of which pointers are non-empty, and then only stores the non-empty TriePtrs. It only does this if this actually saves space over just storing the entire list (storing the entire list is cheaper if the list is nearly full).

  • Instead of copying a trie node from one trie to the next as part of a copy-on-write, the system will only store a patch from the old node to the new node. It will create a list of up to 16 patches across 16 tries before storing a full copy of the node.

In my (very small scale) benchmarks, this saves over 50% of space.

This PR is still a draft and will likely remain so for some time. It needs a lot more unit tests, and it would benefit significantly from fuzz and property testing against the current implementation. In addition, it will need a lot of performance tuning, since the act of reading a list of patch nodes will slow down reads.

.with_compression(true),
MARFOpenOpts::new(TrieHashCalculationMode::Immediate, "noop", true)
.with_compression(true),
*/
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: revert this comment block

+ rusqlite::types::ToSql
+ rusqlite::types::FromSql
+ stacks_common::codec::StacksMessageCodec
+ crate::codec::StacksMessageCodec
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: use stacks_common not crate

#[cfg(test)]
use stacks_common::types::chainstate::BlockHeaderHash;
use stacks_common::types::chainstate::{
use crate::types::chainstate::BlockHeaderHash;
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: use stacks_common not crate

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.

1 participant