Skip to content

perf(sv): simulate sensitivity lists that cover their reads like always @* - #2087

Merged
mergify[bot] merged 1 commit into
masterfrom
feature/perf/2079-level-lists-as-comb
Oct 26, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
feature/perf/2079-level-lists-as-comb

Conversation

@tignear

@tignear tignear commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

rtlmeter's C906 simulated at about 88 cycles/s on the native backend (four-state). Most of the simulation phase went to SimulationState::check_waits: about 720 processes waited on level-sensitive lists, and every round compared the watched signals of all of them (about 3,000 small terms per round, 60 rounds per cycle). These processes are the core's generated combinational blocks, such as always @(a or b[127:0] or c[14:12]). Only an always whose list names exactly the variables of the implicit event expression was simulated like always @* (IEEE 1800-2023 9.4.2.2). A part-select in the list, whether of the whole variable or narrower, kept the block a process.

A level-sensitive list now also simulates like always @* when it covers every bit its statement reads (longest static prefixes) and running the statement more often cannot be observed:

  • the statement calls no subroutine or system task and no system function that reads the simulation;
  • it reads no variable it writes, so a run whose inputs did not change writes the values it wrote last time;
  • it stores each variable at most once per run, so an extra run does not pulse a variable for its waiters (4.3, 9.4.2).

A list that names whole variables through full-width part-selects is now exact as well. Blocks that store a variable twice, such as a default assignment followed by a case, stay processes in both state modes: Celox wakes waiters on intermediate values, so an extra run would be observable, including against Verilator in two-state mode.

C906 hello (native, four-state, heliodor-dev): the simulation phase takes 10.6 s instead of 37.8 s, about 312 cycles/s instead of 88. check_waits falls from about half of the phase to under 5%. The comb processes cost frontend work; #2062 (one unit per process schedule, which this change builds on) recovers most of it.

Closes #2079.

  • Shared cases always_comb::covering_sensitivity_lists_settle_like_a_wildcard and its four-state twin (the untimed harness builds a Simulator, which runs no processes) and always_comb::multi_store_blocks_with_covering_lists_stay_processes (an edge waiter counts no extra pulses), matching Icarus and Verilator.
  • The SystemVerilog reference describes the rule and its reason.

Verification

  • cargo nextest run -p celox -p celox-test-suite -p celox-frontend-sv with CI's features: 14814 passed. clippy (workspace minus lydite, --all-targets -D warnings): clean. retained_reports: passed.
  • verify-sv-icarus --filter always_comb::: 8/8 passed. verify-sv-verilator: 7 passed, 1 unsupported (the four-state twin).
  • sv-tests (2- and 4-state): identical to conformance/sv-tests/expected.tsv.
  • Probe (always @(x[0]) begin p = 0; if (x[0]) p = 1; end with always @(posedge p) n++ and a change of an unlisted bit of x): Icarus and Verilator count 1; rewriting the block would count 2 in Celox, so multi-store blocks stay processes.
  • C906 hello (native, four-state, heliodor-dev; simulation phase from "Init Program" to TEST PASSED): 37.8 s → 10.6 s (~88 → ~312 cycles/s); check_waits + advance ~56% → under 5% of the phase.
  • b2_vm_dispatch_bit callgrind gate (--backend native): step_until identical (4,204,004,002), totals +0.01% (see comment).

Rebased onto master after #2082 merged (9ccb91e); 14950 affected tests pass there.

@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-25T21:59:48.811684Z
We couldn’t complete this review. Comment @codex review to try again.
67c5dc7 PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tignear

tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

b2_vm_dispatch_bit callgrind gate (release builds, taskset -c 8-11, run --backend native --top bench_vm_dispatch --two-state --unlimited, two runs each):

base b6127b0 (#2082) this PR
output BENCH_DONE cycles=200000 checksum=136 same
step_until (inclusive) 4,204,004,002 / 4,204,004,002 4,204,004,002 / 4,204,004,002
PROGRAM TOTALS 21,461,372,542 / 21,464,677,142 21,465,880,951 / 21,466,543,093 (+0.01%)

The default run backend is now tiered, whose split between the interpreter and the native tier depends on when the background compile finishes, so it is not reproducible under callgrind (one tiered run each gave step_until 12.6 G vs 14.9 G with totals 31.5 G vs 30.5 G). The native backend gives the deterministic comparison.

@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 26, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-26 04:03 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • 🚫 Left the queue — 2026-10-26 04:33 UTC · at 67c5dc7151027258d86ad55b5e2027a4780ad507

This pull request spent 29 minutes 25 seconds in the queue, with no time running CI.

Reason

The pull request conflicts with the base branch

The pull request was held in the queue, conflicting with at least one of 2 pull requests ahead of it. The conflict became a base branch one after #2082, #2085 merged.

Hint

You should update or rebase your pull request.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

Base automatically changed from perf/sv-comb-process-unit-once to master October 26, 2026 04:32
@mergify mergify Bot added dequeued Mergify stopped this queue entry; investigate before retrying and removed queued Mergify queue entry labels Oct 26, 2026
…ys @*

rtlmeter's C906 simulated at about 88 cycles/s on the native backend (four-state). Most of the simulation phase went to `SimulationState::check_waits`: about 720 processes waited on level-sensitive lists, and every round compared the watched signals of all of them (about 3,000 small terms per round, 60 rounds per cycle). These processes are the core's generated combinational blocks, such as `always @(a or b[127:0] or c[14:12])`. Only an `always` whose list names exactly the variables of the implicit event expression was simulated like `always @*` (IEEE 1800-2023 9.4.2.2). A part-select in the list, whether of the whole variable or narrower, kept the block a process.

A level-sensitive list now also simulates like `always @*` when it covers every bit its statement reads (longest static prefixes) and running the statement more often cannot be observed:
- the statement calls no subroutine or system task and no system function that reads the simulation;
- it reads no variable it writes, so a run whose inputs did not change writes the values it wrote last time;
- it stores each variable at most once per run, so an extra run does not pulse a variable for its waiters (4.3, 9.4.2).

A list that names whole variables through full-width part-selects is now exact as well. Blocks that store a variable twice, such as a default assignment followed by a `case`, stay processes in both state modes: Celox wakes waiters on intermediate values, so an extra run would be observable, including against Verilator in two-state mode.

C906 hello (native, four-state, heliodor-dev): the simulation phase takes 10.6 s instead of 37.8 s, about 312 cycles/s instead of 88. `check_waits` falls from about half of the phase to under 5%. The comb processes cost frontend work; #2062 (one unit per process schedule, which this change builds on) recovers most of it.

Closes #2079.

- Shared cases `always_comb::covering_sensitivity_lists_settle_like_a_wildcard` and its four-state twin (the untimed harness builds a `Simulator`, which runs no processes) and `always_comb::multi_store_blocks_with_covering_lists_stay_processes` (an edge waiter counts no extra pulses), matching Icarus and Verilator.
- The SystemVerilog reference describes the rule and its reason.

Change-Id: I8fb99a7ef1dbc09969a27024f479ee5f795412e5
@tignear
tignear force-pushed the feature/perf/2079-level-lists-as-comb branch from 67c5dc7 to c42418d Compare October 26, 2026 05:09
@mergify mergify Bot added queued Mergify queue entry and removed dequeued Mergify stopped this queue entry; investigate before retrying labels Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-26 05:34 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • ✅ Checks passed · on draft merge queue: checking #2087 on master (f2934be) #2108
  • ✅ Merged — 2026-10-26 06:04 UTC · at 2eb2a70e849d1af8e2d7e613c9afbae2f47f2a17 · merge

This pull request spent 29 minutes 28 seconds in the queue, including 27 minutes 11 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

@mergify mergify Bot mentioned this pull request Oct 26, 2026
40 of 71 tasks
@mergify
mergify Bot merged commit 2eb2a70 into master Oct 26, 2026
24 checks passed
@mergify
mergify Bot deleted the feature/perf/2079-level-lists-as-comb branch October 26, 2026 06:04
@mergify mergify Bot removed the queued Mergify queue entry label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(runtime): waking processes compares every waiter's watched signals on every round

1 participant