Repository navigation
perf(registry): hash-indexed point lookups instead of linear scans - #94
Merged
Merged
Conversation
resolve/is_known/is_privacy_address/resolve_tx/get_decimals/ get_metadata/viewing_key each scanned the user, known and tx-label Vecs with `find`. Rendered rows call three to five of them, and the address color-map rebuild calls is_known for every row whenever the list grows, which on a busy contract is every WS event. Build Felt -> index HashMaps (first occurrence wins, matching `find`) and a HashSet of privacy addresses once in load(); route all point lookups through them. Iteration-only methods are unchanged. Bench (release, 52k rows, 759 user labels): 3 lookups per row over all rows: 73 ms -> 5 ms, flat in label count. Txs tab frame 1.1 ms -> 0.7 ms; frame with color-map rebuild 2.5 ms. Closes #90. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved issues were identified.
Pull request overview
Improves AddressRegistry lookup performance by replacing linear scans with hash-based indexes while preserving lookup behavior.
Changes:
- Adds indexes for labels, known addresses, transactions, viewing keys, and privacy addresses.
- Routes point lookups through the new indexes.
- Adds regression tests for shadowing and viewing-key lookup.
File summaries
| File | Summary |
|---|---|
tests/registry_test.rs |
Covers lookup behavior and shadowing semantics. |
src/registry/mod.rs |
Implements indexed registry lookups and privacy classification. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Problem
AddressRegistry::resolve,is_known,is_privacy_address,resolve_tx,get_decimals,get_metadata,format_address_fullandviewing_keyeach scanned the user-label, known-address and tx-labelVecs withiter().find(). Every rendered address row calls three to five of them, and the address-tab color-map rebuild (update_tx_color_map/update_call_color_map) callsis_knownfor every row whenever the list grows, which for a busy contract is on every WS event. With ~760 user labels that was ~40MFeltcompares per event on the UI thread.Closes #90.
Change
load()buildsFelt → indexHashMaps for user labels, known addresses, tx labels and viewing keys, plus aHashSet<Felt>oftype = "Privacy"known addresses. First occurrence wins, matching the oldfindsemantics. The known-address dedup during index build uses the map too.user_label,known_addr) or the maps directly. Iteration-only methods (privacy_addresses,iter_viewing_keys,search,resolve_by_name,add_voyager_label) are unchanged.Bench
Release profile, same
TestBackendharness as #93, 52k rows (temporary example, not committed):Lookup cost is flat in label count now.
Tests
is_privacy_addresstrue andget_decimalsstill resolves through a user-shadowed known entry; viewing-key lookup by user address.cargo test,cargo clippy --all-targets(no new warnings),cargo build --release.Follow-ups
select!, coalesce buffered key events.🤖 Generated with Claude Code