Repository navigation
perf(sv-analyzer): avoid cloning scalar call contexts - #1182
Merged
Merged
Conversation
tignear
marked this pull request as ready for review
October 10, 2026 19:02
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. |
tignear
enabled auto-merge
October 10, 2026 19:30
tignear
added this pull request to the merge queue
Oct 10, 2026
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.
Lowering a constant-function initializer such as
f(P + 1)constructedPackedDimensionsby copying every visible numeric binding and type alias, even though those operand-lowering branches do not read declaration metadata. Repeating this across a growing parameter prefix adds quadratic copying.Classify the call operands first. Literals, bare identifiers, unary/binary expressions, parentheses, and nested user calls with those operands use an empty context. Selections, casts, system calls, patterns, conditional expressions, named arguments, and omitted arguments keep the original complete context. Expression lowering and later typed parameter evaluation remain the same.
Based directly on current master (
281f7bd9c), independently of #1175. The standalone constant-function probe mode is compatible with the one in that PR.Validation:
cargo fmt --all -- --checkcargo clippy --locked -p celox-sv-analyzer -p celox-frontend-sv --all-targets --all-features -- -D warningscargo test --locked -p celox-sv-analyzer -p celox-frontend-sv --all-features --quiet: 233 passed; two manual timing probes ignored by the normal suite.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: SystemVerilog 1,685, DPI 52, arrays 7, packages 45, interfaces 216 passed; 39 existing interface exclusions.cargo test --locked -p celox-test-suite --features verilator,icarus --quiet: 56 tests plus two doctests passed; nine existing external-oracle tests remain ignored. Executable shared cases and adapters are unchanged, so external evidence is reused under CONTRIBUTING.md.cargo doc --locked -p celox-sv-analyzer -p celox-frontend-sv --no-depsandpnpm docs:buildpassed.The internal comparison exercises 21 argument forms against the former full-context lowering with 4,096 unrelated bindings, including signed parameters, symbolic/typedef casts, selects, size queries, zero divisions, nested calls, and unsupported forms. A 16/64/256-parameter source-to-IR arithmetic chain checks every value and zero context copies. The large debug regression uses an 8 MiB thread stack for existing recursive parameter substitution.
The optimized paired probe (
compare_lazy_and_copied_scalar_call_contexts -- --ignored --nocapture) passed. With 512 unrelated parameters and 512 scalar call conversions, the seven-run median was 23.827 ms for full contexts versus 1.473 ms for classified contexts. It checks converted calls and excludes source parsing and function-body execution.The standalone
type_queries --constant-functions 32 128 512probe passed with IR value assertions. At 512 parameters, separate three-sample medians comparing master with this change were 2,699.106 → 1,720.513 ms for AST lowering (parse 49.174 → 53.607 ms). The 32-parameter AST sample became slower (19.841 → 22.680 ms). Full results and commands are in the performance document; shared-machine timing varies and whole AST lowering remains nonlinear.A diagnostic run with #1175 applied counted 18N function executions at N=16/64/256: the function-call count itself was linear. The performance notes distinguish that count from growing costs inside each call, repeated collection passes, and unresolved expression expansion. This change removes one environment-copying path; other contexts, declaration discovery, and unresolved expression expansion remain.