Skip to content

perf(runtime): share the interpreter's combinational program across clocks - #2009

Merged
mergify[bot] merged 1 commit into
masterfrom
perf/2004-interp-shared-comb
Oct 25, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
perf/2004-interp-shared-comb

Conversation

@tignear

@tignear tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Closes #2004.

Summary

InterpBackend::new built a separate combined program for every eval/apply clock without a fused schedule, consisting of a fresh prepare_units(&eval_comb) plus a second copy of the clock's FF units. It also cloned comb_trigger_addrs into each clock's trigger list. Memory and build time were O(clocks × comb size), and the tiered and interpreter backends ran out of memory on C906.

Now:

  • eval_comb is prepared once (eval_comb_units, which already existed). A combined tick of a clock without a fused schedule runs eval_comb_units and then the clock's eval_apply_units as one group, with one trigger snapshot at group entry as before. run_units takes an iterator of units for this. Only clocks with a fused schedule keep their own prepared list (fused_comb_apply_units).
  • Sharing the prepared units between eval_comb() and the combined tick does not change results: Registers are generation-stamped on every execution, so no state carries over between runs.
  • Each clock keeps only its FF units' trigger addresses (the union over its eval/apply, eval-only and apply groups), plus a flag for whether the combinational addresses belong to its groups (eval/apply clocks). At group entry, TriggerAddrs iterates the union of the shared combinational list and the clock's list in sorted order, each address once. The snapshots are the same sorted, deduplicated list as before.
  • The combined tick borrows two slices instead of boxing an iterator, so the per-tick path does not allocate.

I also read the rest of InterpBackend::new and the per-tick paths: eval_comb, eval_apply_ff_at, eval_comb_apply_ff_at, eval_only_ff_at, apply_ff_at and run_process. The eval/apply, eval-only, apply and process units are each prepared once, and the per-tick paths reuse the snapshot buffer, so no other per-clock copy was left. One remaining duplication is not in the interpreter: events with identical fused SIR (clock and reset aliases, apply_fused_optimization_hints) each get their own eval_comb_apply_ffs entry in the SIR program, so each one is prepared separately.

Tests

  • combined_ticks_of_several_clocks_match_the_compiled_backend: a three-clock design with combinational logic between the domains. It runs a fixed sequence of deferred-comb ticks (the combined comb+FF path) on the interpreter and on Cranelift and compares all outputs after every step.
  • trigger_addrs_iterate_the_union_in_order: the merged trigger list equals the sorted, deduplicated concatenation for overlapping, disjoint and empty lists.
  • The whole celox test suite with --features systemverilog (the all_backends! interpreter variants included); see below.

Per the decision for complexity-order fixes, no benchmarks were run.

Local run: cargo nextest run -p celox --features systemverilog under the memory cap gave 14635 passed, 0 failed, 313 skipped. Clippy (--lib --tests --features systemverilog) and fmt are clean.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-25T14:13:36.309526Z dfc09d0 New commits
ℹ️ 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 added the merge-ready Request merging through Mergify after required checks label Oct 25, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 25, 2026
@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 14 minutes 13 seconds in the queue, including 1 hour 47 seconds running CI.

Reason

The merge conditions cannot be satisfied due to failing checks

  • Queue validation
  • Rust Test & NAPI Build

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for
  • check-success = Queue validation
  • any of: [🛡 GitHub repository ruleset rule master]
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
    • check-success = @github-actions/Rust Test & NAPI Build
All conditions
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
    • check-success = @github-actions/Rust Test & NAPI Build
  • check-success = Conventional Commit title
  • 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/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

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

…locks

Closes #2004

Change-Id: I25c5836030d05db672adcb2159c9aa2fdb9e7890
@tignear
tignear force-pushed the perf/2004-interp-shared-comb branch from 1ea32b4 to dfc09d0 Compare October 25, 2026 14:12
@tignear tignear removed the dequeued Mergify stopped this queue entry; investigate before retrying label Oct 25, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 25, 2026
@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 42 minutes 9 seconds in the queue, including 34 minutes 2 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 merged commit da01037 into master Oct 25, 2026
23 checks passed
@mergify
mergify Bot deleted the perf/2004-interp-shared-comb branch October 25, 2026 15:24
@mergify mergify Bot removed the queued Mergify queue entry label Oct 25, 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(interp): every clock gets its own copy of the prepared combinational program

1 participant