-
Notifications
You must be signed in to change notification settings - Fork 19
feat(delayed-persist): dump unpersisted nodestore #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dump has to work with unpersisted nodes, as there are a bunch of tests that assume an immutable proposal can be dumped. This was useful anyway while debugging some tests in the next commit, and small enough to commit separately.
rkuris
commented
Jul 12, 2025
/// Returns the root of the trie as a `MaybePersistedNode`. | ||
/// Callers that might want to modify the root or know how it is stored | ||
/// should use this function. | ||
fn root_as_maybe_persisted_node(&self) -> Option<MaybePersistedNode>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a future diff, this will just be called root
but I want it verbose during the rest of the development of this feature as it helped identify areas still to changed.
demosdemon
approved these changes
Jul 14, 2025
rkuris
added a commit
that referenced
this pull request
Jul 15, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The commit logic is also different, with far fewer steps. See the comments in `commit` in manager.rs. Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 15, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The commit logic is also different, with far fewer steps. See the comments in `commit` in manager.rs. Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 16, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The commit logic is also different, with far fewer steps. See the comments in `commit` in manager.rs. Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 16, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The commit logic is also different, with far fewer steps. See the comments in `commit` in manager.rs. Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 17, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The commit logic is also different, with far fewer steps. See the comments in `commit` in manager.rs. Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
KushnerykPavel
pushed a commit
to KushnerykPavel/firewood
that referenced
this pull request
Jul 17, 2025
dump has to work with unpersisted nodes, as there are a bunch of tests that assume an immutable proposal can be dumped. This was useful anyway while debugging some tests in the next commit, and small enough to commit separately.
rkuris
added a commit
that referenced
this pull request
Jul 19, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The commit logic is also different, with far fewer steps. See the comments in `commit` in manager.rs. Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 19, 2025
Create a new type, NodeAllocator, to handle allocations. Currently only uses references to the original NodeStore, but this will change in an upcoming diff. Also: - Branch children iterators will soon no longer be able to return references to hashes, since they are behind an ArcSwap, so they are now cloned. - Added logger feature to benchmark (helped with debugging) - Remove use of stored_len in tests feat(deferred-allocate): Part 3.2: Implementation This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The commit logic is also different, with far fewer steps. See the comments in `commit` in manager.rs. Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 19, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The implementation constisted of: - A new type, NodeAllocator, to consolidate all the allocation code - Removing the 'new' hashmap, as freshly allocatred nodes are found by traversing the trie and inspecting their state - Rewrite flush_nodes to serialize then allocate. Previously, the node was serialized twice, once to determine the size during proposal creation and once to store it - Branch children iterators can no longer return reference to hashes, since they are sometimes behind an ArcSwap - Changes to the commit flow by separating the node persistence logic Some miscellaneous changes included in this diff (could be split out): - Propogate logger feature in fwdctl (helped with debugging) - Remove use of stored_len in tests - size_from_area_index was a method on nodestore, but didn't use nodestore - uncached_node_and_size was dead code Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 20, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The implementation constisted of: - A new type, NodeAllocator, to consolidate all the allocation code - Removing the 'new' hashmap, as freshly allocatred nodes are found by traversing the trie and inspecting their state - Use the most recently committed revision's freelist to allocate new nodes. This will change in a future revision when the freelist is tied to storage rather than the revision. - Rewrite flush_nodes to serialize then allocate. Previously, the node was serialized twice, once to determine the size during proposal creation (allocation time) and once to store it - Changes to the commit flow by separating the node persistence logic (see comments in commit.rs) Some miscellaneous changes included in this diff (could be split out): - Branch children iterators can no longer return reference to hashes, since they are sometimes behind an ArcSwap - Propogate logger feature in fwdctl (helped with debugging) - Remove use of stored_len in tests - size_from_area_index was a method on nodestore, but didn't use nodestore - uncached_node_and_size was dead code Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 21, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The implementation constisted of: - A new type, NodeAllocator, to consolidate all the allocation code - Removing the 'new' hashmap, as freshly allocatred nodes are found by traversing the trie and inspecting their state - Use the most recently committed revision's freelist to allocate new nodes. This will change in a future revision when the freelist is tied to storage rather than the revision. - Rewrite flush_nodes to serialize then allocate. Previously, the node was serialized twice, once to determine the size during proposal creation (allocation time) and once to store it - Changes to the commit flow by separating the node persistence logic (see comments in commit.rs) Some miscellaneous changes included in this diff (could be split out): - Branch children iterators can no longer return reference to hashes, since they are sometimes behind an ArcSwap - Propogate logger feature in fwdctl (helped with debugging) - Remove use of stored_len in tests - size_from_area_index was a method on nodestore, but didn't use nodestore - uncached_node_and_size was dead code Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 22, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The implementation constisted of: - A new type, NodeAllocator, to consolidate all the allocation code - Removing the 'new' hashmap, as freshly allocatred nodes are found by traversing the trie and inspecting their state - Use the most recently committed revision's freelist to allocate new nodes. This will change in a future revision when the freelist is tied to storage rather than the revision. - Rewrite flush_nodes to serialize then allocate. Previously, the node was serialized twice, once to determine the size during proposal creation (allocation time) and once to store it - Changes to the commit flow by separating the node persistence logic (see comments in commit.rs) Some miscellaneous changes included in this diff (could be split out): - Branch children iterators can no longer return reference to hashes, since they are sometimes behind an ArcSwap - Propogate logger feature in fwdctl (helped with debugging) - Remove use of stored_len in tests - size_from_area_index was a method on nodestore, but didn't use nodestore - uncached_node_and_size was dead code - New clippy lint for hash_helper not needing &self in non-ethhash fixed Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 22, 2025
This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The implementation constisted of: - A new type, NodeAllocator, to consolidate all the allocation code - Removing the 'new' hashmap, as freshly allocatred nodes are found by traversing the trie and inspecting their state - Use the most recently committed revision's freelist to allocate new nodes. This will change in a future revision when the freelist is tied to storage rather than the revision. - Rewrite flush_nodes to serialize then allocate. Previously, the node was serialized twice, once to determine the size during proposal creation (allocation time) and once to store it - Changes to the commit flow by separating the node persistence logic (see comments in commit.rs) Some miscellaneous changes included in this diff (could be split out): - Branch children iterators can no longer return reference to hashes, since they are sometimes behind an ArcSwap - Propogate logger feature in fwdctl (helped with debugging) - Remove use of stored_len in tests - size_from_area_index was a method on nodestore, but didn't use nodestore - uncached_node_and_size was dead code - New clippy lint for hash_helper not needing &self in non-ethhash fixed Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
rkuris
added a commit
that referenced
this pull request
Jul 23, 2025
feat(deferred-allocate): Part 3: Defer allocate This implements deferred allocaion that delays allocating space for nodes until commit time. The nodestore refactor consisted of removing the 'new' hashmap, which mapped newly allocated nodes to their contents in a proposal. Instead, now we store those newly allocated nodes directly from the `Child` struct. The implementation constisted of: - A new type, NodeAllocator, to consolidate all the allocation code - Removing the 'new' hashmap, as freshly allocatred nodes are found by traversing the trie and inspecting their state - Use the most recently committed revision's freelist to allocate new nodes. This will change in a future revision when the freelist is tied to storage rather than the revision. - Rewrite flush_nodes to serialize then allocate. Previously, the node was serialized twice, once to determine the size during proposal creation (allocation time) and once to store it - Changes to the commit flow by separating the node persistence logic (see comments in commit.rs) Some miscellaneous changes included in this diff (could be split out): - Branch children iterators can no longer return reference to hashes, since they are sometimes behind an ArcSwap - Propogate logger feature in fwdctl (helped with debugging) - Remove use of stored_len in tests - size_from_area_index was a method on nodestore, but didn't use nodestore - uncached_node_and_size was dead code - New clippy lint for hash_helper not needing &self in non-ethhash fixed Task completion status: [x] Roots may not be persisted (Part 1: #1041) [x] BranchNode children can now be Node, LinearAddress or a MaybePersistedNode (Part 2: #1045 and #1047) [x] When converting a `MutableProposal` to an `ImmutableProposal`, don't actually allocate space, just create `SharedNode`s from the `Node`s. (Part 3: #1055 and this PR) [ ] Remove `NodeStoreHeader` from `NodeStore`. The header should move into the `RevisionManager`. [ ] Allocate new nodes from the recently-freed nodes from an expired revision, then from the freelist. This can be done by maintaining a local freelist from the nodes deleted in the expiring revision and falling back to the actual freelist. Deleted nodes that are not reused must still be pushed onto the freelist.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
dump has to work with unpersisted nodes, as there are a bunch of tests that assume an immutable proposal can be dumped. This was useful anyway while debugging some tests in the next commit, and small enough to commit separately.