Skip to content
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

Traverse trie branches in same stack frame #6981

Merged
merged 2 commits into from
May 6, 2024
Merged

Traverse trie branches in same stack frame #6981

merged 2 commits into from
May 6, 2024

Conversation

benaadams
Copy link
Member

@benaadams benaadams commented May 5, 2024

Changes

  • Shrink TraverseBranch(es) method (for smaller loop body) and change to a loop as branches can go quite deep, so branches are all traversed in one method call
    • Less stack spaces setup, returned through, etc
  • seal HealingTrieStore and ScopedTrieStore
  • Also makes perf traces easier to evaluate as is less branching at lots of different points

Before

image

After

image

Also Before (showing how deep it goes)

image

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • No

@benaadams benaadams requested review from LukaszRozmej and asdacap May 5, 2024 00:37
[StackTraceHidden]
static ref readonly CappedArray<byte> TraverseBranch(TrieNode node)
{
throw new InvalidOperationException($"Branch node {node.Keccak} should already be handled");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think its possible that it traverse from branch to extension then back to branch.

Copy link
Member Author

Choose a reason for hiding this comment

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

Have tenary inside TraverseExtension that calls TraverseBranches direcly so should be ok.

Copy link
Member Author

@benaadams benaadams May 5, 2024

Choose a reason for hiding this comment

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

For Extension

Before

image

After

image

Copy link
Contributor

@asdacap asdacap left a comment

Choose a reason for hiding this comment

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

LGTM

@benaadams benaadams merged commit 4e98f26 into master May 6, 2024
67 checks passed
@benaadams benaadams deleted the branches branch May 6, 2024 09:57
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.

2 participants