perf(common): index artifact bytecode matching - #16080
Open
mattsse wants to merge 2 commits into
Open
Conversation
Bucket exact deployed-bytecode candidates by length and cache normalized match plans while retaining artifact selection order. At 5,000 artifacts, Criterion steady-state middle/last/miss lookups improve from 3.815/7.935/7.216 us to 124/214/15.9 ns.
mattsse
requested review from
0xrusowsky,
DaniPopes,
figtracer,
grandizzy,
mablr and
stevencartavia
as code owners
August 8, 2026 07:25
Contributor
✅ Changelog foundThe deterministic check will validate the changed entry. |
Member
|
i think we don't need these huge changes for average 100ns save |
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.
ContractsByArtifactnow keeps exact deployed-bytecode candidates in ordered code-length buckets and lazily prepares each candidate's ignored ranges and unlinked-bytecode representation. The buckets are populated in the existingBTreeMaporder, the first fully linked artifact retains a direct fast path, and query metadata is parsed once, preserving the existing earliest-exact and last-partial selection behavior across metadata, immutables, link references, placeholders, and library call protection. This complements #16069's linker path index; it does not change linker resolution.Candidates store only the artifact id, the match bytecode, and the ignored ranges; a hit resolves back through the artifact map instead of retaining a clone of the contract data, so building the index does not duplicate ABIs or bytecode. That lookup costs roughly 0.3 µs per exact or partial hit and shows up in the small-set
middle/lastrows below, while misses — which don't touch the map at all — and larger artifact sets stay well ahead of the linear scan.Results
Criterion 0.7 steady-state medians against
master(7c271517a3), same machine and run, using identical 128-length-bucket artifact sets:100 / first100 / middle100 / last100 / miss1,000 / first1,000 / middle1,000 / last1,000 / miss5,000 / first5,000 / middle5,000 / last5,000 / missThe
+rows are exact hits in small artifact sets where the final id lookup dominates; the callers (cheatcodes,verify) pay it once per matched query and mostly issue misses against foreign code, which is where the old scan was spending its time.This PR was written with Codex, including the implementation, tests, benchmarks, and pull request text.