perf(agglayer): selective frontier load/save in B2AGG processing#2752
Open
perf(agglayer): selective frontier load/save in B2AGG processing#2752
B2AGG processing#2752Conversation
6acc903 to
e8704e4
Compare
90286c5 to
949890c
Compare
e8704e4 to
0273ef4
Compare
B2AGG processing
Replace unconditional load/save of all 32 LET frontier entries with selective operations based on the bit pattern of num_leaves: - load_let_frontier_selective: only loads entries where bit h=1 (entries that will be READ by append_and_update_frontier) - save_let_frontier_selective: only saves entries where bit h=0 (entries that were WRITTEN by append_and_update_frontier) This halves the number of storage map syscalls from 128 to 64 per B2AGG note consumption. Cycle savings vary by frontier occupancy: - Empty tree (0 leaves): 145k -> 116k (-20%) - Populated tree (2^31-1 leaves): 140k -> 60k (-57%) Also adds benchmarks with pre-populated frontier states (2^31 and 2^31-1 leaves) to measure the impact across different access patterns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0273ef4 to
eebff52
Compare
Fumuran
approved these changes
Apr 16, 2026
Contributor
Fumuran
left a comment
There was a problem hiding this comment.
Looks great, thank you! I left a few (mostly format) nits inline
- Add v0.15.0 CHANGELOG entry for selective frontier optimization - Add newline after stack comment to separate logic blocks - Move add.1 to same line as swap u32shr.1 swap - Use if.false instead of eq.0 if.true for bit check - Add stack comment after double_word_array::set https://claude.ai/code/session_01GjjUe9KUggLJMAdiuBw8vk
Fumuran
reviewed
Apr 17, 2026
Contributor
There was a problem hiding this comment.
Not sure that we should remove the whole changelog before v0.14.1 😁
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
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.
Summary
num_leavesload_let_frontier_selective: only loads entries where bit h=1 (entries that will be READ byappend_and_update_frontier)save_let_frontier_selective: only saves entries where bit h=0 (entries that were WRITTEN byappend_and_update_frontier)Cycle counts (note_execution)
Turns out that #2618 was not merged into
mainnornext(by commit history, it looks like it was merged intoagglayerbranch short afteragglayergot merged intonext).See #2753
Test plan
bridge_out_consecutive(32 sequential B2AGG notes verified against Solidity roots)bridge_out_fails_with_unregistered_faucetb2agg_note_non_target_account_cannot_consumeb2agg_note_reclaim_scenariomake lintpasses🤖 Generated with Claude Code