Skip to content

perf(runtime)!: skip compiled settles whose inputs did not change - #1811

Merged
mergify[bot] merged 4 commits into
masterfrom
feature/compiled-scheduler-3b6
Oct 23, 2026
Merged

mergify[bot] merged 4 commits into
masterfrom
feature/compiled-scheduler-3b6

Conversation

@tignear

@tignear tignear commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Part of #1123, step 3b-1 (compiled scheduler), PR 6 of 7. Builds on #1805.

A compiled slot settles combinational logic after every pass of the process phase and after the domains, as the reference loop does. It now skips a settle when nothing combinational logic reads changed since the last one. The testbench shape (b1) drops from about 1,260 to about 900 Ir per cycle, below Simulator::tick (a, 969); delay-only designs such as (d) from about 967 to about 728.

Slots that run in the Rust reference loop are unchanged and settle as before.

BREAKING CHANGE

  • celox_design::SchedulerSlots (public) has a new field, dirty.
  • Native images use container format 32; images written by earlier versions must be rebuilt.

Stacked on #1805: review the last commit (perf(runtime)!: skip compiled settles whose inputs did not change).

The rule

  • What combinational logic reads is structural: the storage its units load or commit from (shared storage resolved), taken from the comb units' SIR at generation. No value analysis.
  • Every write path inside a run marks a change (the dirty slot) when it may touch that storage:
    • an inlined kernel, eval_apply, eval_only or apply unit whose stores or commits name any of it (after the unit, whichever path the unit took);
    • a published nonblocking value whose target is in it;
    • a host clock's level, when combinational logic reads the clock;
    • the time slots, when combinational logic reads the time;
    • the start of each run, for anything the host wrote before it.
  • A settle runs when the mark is set and clears it; otherwise it is skipped. Combinational logic writes only what it computes from what it reads, so a settle with unchanged inputs writes what it already holds.
  • Every settle runs when combinational logic has effects of its own: runtime event records, comb captures, external (DPI) calls, or stores and commits with trigger marks.

The start-of-run mark is a safety margin: every compiled run follows a slot the reference loop settled (a host write sets host-pending, which the reference loop handles first), so no test fails without it; it costs one store per run.

Perf

Callgrind, whole program, Ir per cycle = (Ir at 200,000 cycles − Ir at 20,000) / 180,000, median of 5. Base: #1805's head (594c565), the same bench file.

Case base branch change
(a) Simulator::tick 969.0 969.0 0
(ac) Simulation + add_clock 6,093.0 6,093.0 0
(b1) always #5 clk = ~clk + forever @(posedge clk) stim = stim + 3 + RTL 1,259.2 899.4 −28.6%
(b5) the same with stim <= stim + 3 1,281.8 913.2 −28.8%
(bh) (b1) with add_clock(10, 5) instead of the clock kernel 1,089.6 851.0 −21.9%
(d) always #5 clk = ~clk + RTL 966.6 727.7 −24.7%
(dr) (d) with an asynchronous reset input on every register 1,233.0 990.4 −19.7%
  • Each case settles once a cycle instead of three or four times: after the rising edge's domain. The kernels write the clock and stim, which only the registers read, and the falling edge triggers nothing.
  • (a) and (ac) have no compiled scheduler.
  • Totals at 20,000 cycles, base → branch: (a) 316.34M → 316.40M, (ac) 418.83M → 418.89M, (b1) 489.26M → 486.25M, (b5) 498.36M → 493.01M, (bh) 474.93M → 472.04M, (d) 456.49M → 456.26M, (dr) 944.68M → 941.18M.

Validation

  • cargo test -p celox --features systemverilog --test systemverilog (all groups, native/cranelift/parallel/wasm): 4,222 passed, 20 ignored in each of CELOX_SCHEDULER=differential, differential-runs and the default (compiled).
  • --lib: 202 passed. A new test runs combinational logic that reads, on slots where no domain triggers, a kernel's blocking write, a published nonblocking value, a host clock's level and a host input written between runs, besides a domain's registers, in the compiled, differential and differential-runs modes on the native and Cranelift backends, comparing the state file (combinational outputs included) with the reference's after every run. Removing the mark of the unit writes, of the publication or of the host clock each fails it.
  • The host-clock tests of feat(runtime)!: host periodic clocks in the compiled loop #1805 (host writes between runs, state files, checkpoints) pass with elision on.
  • 44 integration test files (state_file, checkpoint, vcd, shared_jit_cache with image format 32, ...), celox-runtime, celox-design, celox-frontend-core, celox-sir, celox-heap: all passed.
  • napi build --platform --target wasm32-wasip1-threads (WASI SDK 25): builds.
  • clippy -D warnings (tests, examples) and cargo fmt --check: clean.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-23T13:55:36.711405Z cd13438 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.

@mergify

mergify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

@tignear
tignear force-pushed the feature/compiled-scheduler-3b6 branch from b83b040 to a1efedf Compare October 23, 2026 11:22
The compiled scheduler now also runs kernels whose every wait is the
same single edge of a one-bit signal that one compiled delay-only
kernel alone drives, whose statuses are Wait, Nba, Done or Finish, and
whose nonblocking sites stage their values into targets nothing else
writes. Such a kernel wakes at most once a slot, so a site is never
staged again before the NBA region.

A slot runs the ready kernels lowest first, tests the waits after each
run while kernels remain ready or the kernel resumes at once, and again
after each pass's settle, as the reference's process phase does; a wait
compares against a baseline that follows every tested change. The
ready set is a mask over the compiled kernels in kernel order. Staged
values publish after the domains, or with a settle of their own without
one. Waiting kernels move between Waiters and the scheduler's slots at
each run, and a run that ends in the middle of a slot hands back the
ready set and the baselines as the reference leaves them. Kernels that
drive or wait for a clock whose domain commits blocking results in the
active region keep the reference loop.

A staged site's target must also lie outside every occurrence probe: the
reference publishes nonblocking updates through the runtime, which bumps
the probes' counters, and the scheduler's publication does not.

BREAKING CHANGE: SchedulerSlots has new fields, `ready` and `baseline`.
Native images use container format 30; images written by earlier
versions must be rebuilt.

Change-Id: Ib033a13b9ad213155c0ffca86c4e891fe61876b2
@tignear
tignear force-pushed the feature/compiled-scheduler-3b6 branch from a1efedf to 36c12a5 Compare October 23, 2026 12:50
A delay-only kernel that pulses the signal another kernel waits on
within one activation, by two stores or in a loop, makes the frontend
count the signal's occurrences, and the compiled scheduler leaves a
design that counts occurrences to the reference loop. The test checks
that every mode wakes on each pulse as the reference does, the guard
for when counted designs become compilable.

Change-Id: I479dec1591e33514389937797b7283eb3baefba2
Periodic clocks from add_clock now run inside the compiled scheduler's
loop when their event is a one-bit clock edge (not an asynchronous
reset) that no design code writes, whose
domain does not commit blocking results in the active region, and the
queue holds exactly one periodic edge of the event's own signal. Every
other scheduled event stays in the Rust queue and ends a compiled run
before its time.

A slot applies the clocks due at its time, in event order, before any
kernel runs and tests the waits once after them; their edges start the
slot's edges and chain with the kernels' writes into the domains. At
the end of the slot each clock whose edge applied waits for its opposite
level half a period later, with the extra unit of an odd period in the
high phase; a next edge past the end of time fails the run as the
reference does, after the clocks before it re-armed. Clock edges move
between the event queue and the scheduler's clock slots at every run;
a run that ends in the middle of a slot leaves the clocks that fired in
it out of the queue, as the reference leaves them.
A run that takes no clock skips the clock code of its slots behind one
test of the armed mask.

A kernel that waits for one edge also compiles when no design code
writes its one-bit signal: a host clock, or an input the host writes
between runs, changes in a compiled slot only at its start.

State files list the queued events in the order they fire instead of
the queue's internal order, which depends on the order of the pushes.

BREAKING CHANGE: SchedulerSlots has new fields, `clock_next`,
`clock_period`, `clock_value` and `clock_armed`; SchedulerSchema has
`clocks` and SchedulerExit has `ClockOverflow`. Native images use
container format 31; images written by earlier versions must be
rebuilt.

Change-Id: I3b7e4561ecbf897a5bf1f4e6d83dc5f3e2697311
A compiled slot settles combinational logic after every pass of the
process phase and after the domains. It now skips a settle when nothing
combinational logic reads changed since the last one. What it reads is
structural: the storage its units load or commit from. Every write path
inside a run marks a change when it may touch that storage: an inlined
kernel or domain unit whose stores do, a published nonblocking value, a
host clock's level, the time slots, and the start of each run for what
the host wrote before it. Combinational logic with records, captures,
external calls or trigger marks settles every time.

BREAKING CHANGE: SchedulerSlots has a new field, `dirty`. Native images
use container format 32; images written by earlier versions must be
rebuilt.

Change-Id: I31ed70b330f7f42680f4cb0c3b5494c6d3012bcd
@tignear
tignear force-pushed the feature/compiled-scheduler-3b6 branch from 36c12a5 to cd13438 Compare October 23, 2026 13:51
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 23, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 23, 2026
@mergify

mergify Bot commented Oct 23, 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 13 minutes 29 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 119000e into master Oct 23, 2026
30 checks passed
@mergify
mergify Bot deleted the feature/compiled-scheduler-3b6 branch October 23, 2026 16:27
@mergify mergify Bot removed the queued Mergify queue entry label Oct 23, 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.

1 participant