Repository navigation
perf(sv-analyzer): avoid repeated four-state environment copies - #1170
Merged
Merged
Conversation
tignear
marked this pull request as ready for review
October 10, 2026 10:57
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Four-state parameter chains copied the growing numeric environment during every literal resolution, and width lowering copied two maps whenever any prefix literal was nonnumeric. Borrow literal-resolution inputs when there is no stale self-value to remove. For pure range headers with the same immutable base, borrow the range context unless a nonnumeric prefix binding masks an inherited numeric value.
The inherited-shadow condition is initialized once and updated conservatively with a direct name lookup for each binding, avoiding repeated prefix scans. Stale self-values, inherited numeric shadows, different bases and assignment-containing headers retain their previous copied/masked projections. Declared widths, signing, X/Z masks, overrides and diagnostics remain unchanged.
Owning-crate tests verify zero width/literal environment copies through complete AST and IR construction for 16/64/256 module and reverse generate chains. They check parameter masks, signal names/widths and generated assignments. Borrowed/copied comparisons cover inherited shadows, constructor/appended prefix parity, 4,096 unrelated bindings, stale self-values, wide literals, signed shifts, two-state conversion and unresolved names. No shared executable cases or external adapters are changed.
Performance
New
type_queries --four-state-parametersmode: forward module chains and reverse generate chains starting with'x, with final generated$bits(P0)and assignment assertions. Medians of three fresh parse/AST/IR runs in optimizedheliodor-dev, excluding backend compilation and simulation. Before is the synchronized tree7e4f3f1bc; after is the additional patch.After 16x input growth, AST time grows 8.9x for the module and 18.6x for the generated input. The large module sample is about 2.9x faster, while small module timings got worse with increased load. Parsing at 512 was 115.117/166.772 ms for the module and 146.045/214.184 ms for generate. Shared-machine variation is substantial; deterministic copy counters establish the removed work independently of timing ratios.
These original timing samples precede the later master system-function/query updates. Preliminary generated
$bitsdiscovery was still costly in the measured tree. This change does not claim a material overall generate speedup or linear scaling for every scope pattern. Phase timings, limitations and reproduction commands are indocs/internals/sv-analysis-performance.md.Validation
Validated after synchronizing master
7565d94cb(including merged #1168), with Rust 1.99.0 in the locked Nix environment and default mbx-managed Cargo targets:cargo clippy --locked -p celox-sv-analyzer -p celox-frontend-sv --all-targets --all-features -- -D warnings.cargo test --locked -p celox-sv-analyzer -p celox-frontend-sv --all-features --quiet— 227 passed; doctests passed.cargo test --locked -p celox --features sv-dpi --test systemverilog --test sv_unpacked_array --test sv_dpi --test sv_packages --test interface --test advanced_interface --quiet— 1,617 SV, 52 DPI, 7 array, 37 package and 216 interface tests passed; 39 existing interface exclusions remain. Native/Cranelift/Wasm and applicable parallel/four-state variants are included.cargo test --locked -p celox-test-suite --features verilator,icarus --quiet— 52 library/integration tests and 2 doctests passed; 9 existing external oracles ignored.cargo doc --locked -p celox-sv-analyzer -p celox-frontend-sv --no-depsandpnpm docs:build.pnpm docs:buildresult is retained.Analyzer-only changes against unchanged shared cases do not require external reruns under AGENTS.md/CONTRIBUTING.md. Retained reports and proof manifests are unchanged. Public APIs/bindings are unchanged; default NAPI does not enable this frontend.