Skip to content

perf(sv-analyzer): retain resolved parameter literals - #1174

Merged
tignear merged 1 commit into
masterfrom
perf/sv-parameter-value-resolution
Oct 10, 2026
Merged

tignear merged 1 commit into
masterfrom
perf/sv-parameter-value-resolution

Conversation

@tignear

@tignear tignear commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Parameter binding and AST-to-IR conversion resolved a nonnumeric value twice: numeric fallback first produced an X/Z or wide literal and discarded it, then the caller resolved the same literal again for publication. Return the numeric result and fallback literal together so each binding resolves a literal at most once.

Direct numeric values still skip literal resolution. A number recovered from a fallback literal retains numeric precedence, while unknown/wide literals remain available to dependent declarations. Unresolved expressions, type-publication order, numeric formatting and the generate binder's existing fallback are preserved. The result is local to each binding; no cache crosses declarations or analyses. Public APIs are unchanged.

Owning-crate regressions compare against the former two-stage resolver for dependencies, selects, signed shifts, stale self-values, two-state conversion, wide values and unresolved names. They verify numeric recovery from an unknown dependency and the generate binder's unresolved fallback. Complete module AST/IR runs at 16/64/256 parameters count one literal evaluation per binding and per exported IR parameter, instead of two.

Performance

Base: synchronized master ef37b2c6c (#1170). A manual optimized heliodor-dev probe replays the same synthetic unknown prefix with both resolvers in one process, alternates their order, asserts every 32-bit X mask and reports seven-run medians:

Parameters Old two-stage (ms) Retained result (ms) Literal calls before/after
32 0.570 0.361 64 / 32
128 6.296 1.548 256 / 128
512 28.168 10.178 1,024 / 512

The large replay sample is about 2.8x faster. This measures value resolution, metadata publication and mask checks, excluding parsing, enclosing-declaration discovery and backend/simulation work. Counts establish the eliminated second evaluation independently of timing variability.

Separate full AST runs do not establish an overall speedup on the shared machine: at 512 four-state module parameters, AST time was 285.531/481.522 ms before/after while parsing was 80.219/137.527 ms; reverse-generate AST was 3,961.605/8,534.573 ms while parsing was 85.630/209.199 ms. Preliminary generated size queries still dominate that path. Detailed phase timings and limitations are retained in docs/internals/sv-analysis-performance.md; no universal speedup or linearity is claimed.

Validation

Locked Nix shell, default managed Cargo targets:

  • Formatting and 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 — 230 passed; doctests passed. The new manual timing probe is deliberately ignored in ordinary runs and was executed separately.
  • 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. Includes native/Cranelift/Wasm and applicable parallel/four-state variants.
  • 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-deps and pnpm docs:build.
  • Manual paired probe: cargo test --locked -p celox-sv-analyzer --profile heliodor-dev --lib compare_retained_and_repeated_parameter_resolution -- --ignored --nocapture — passed.
  • Existing four-state, numeric and ranged type_queries modes at 32/128/512 entries, asserting their IR outputs.

No shared executable cases, external adapters/emitter or retained proof/report artifacts change. External simulators were not rerun for this analyzer-only optimization under AGENTS.md/CONTRIBUTING.md. Default NAPI does not enable this frontend.

@tignear
tignear marked this pull request as ready for review October 10, 2026 12:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T12:38:45.646296Z 21eb07c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tignear
tignear enabled auto-merge October 10, 2026 12:45
@tignear
tignear added this pull request to the merge queue Oct 10, 2026
Merged via the queue into master with commit 54384f1 Oct 10, 2026
25 checks passed
@tignear
tignear deleted the perf/sv-parameter-value-resolution branch October 10, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant