Skip to content

perf(runtime)!: compare counted wait baselines in place - #1803

Merged
mergify[bot] merged 2 commits into
masterfrom
feature/perf/wait-counter-baseline
Oct 23, 2026
Merged

mergify[bot] merged 2 commits into
masterfrom
feature/perf/wait-counter-baseline

Conversation

@tignear

@tignear tignear commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Part of #1123. Follow-up to #1726: the Baseline::Counter check cost.

Problem

A wait term on a counted signal (one whose intermediate writes are counted, #1726) kept the signal's value at its last check as a (BigUint, BigUint) pair. Every check_waits call read the signal into two new BigUints, compared them with occurs and replaced the baseline, which meant allocations and frees on every check. That is why (c), a watched always_comb pulse, cost as much as the always @* path (cs).

Change

  • New variant: Baseline::RawCounter { seen, raw } keeps the counted signal's plane image, the same representation an uncounted plain signal already uses (Baseline::Raw). A check compares it with the state in place, via advance, planes_equal and planes_occur, so it allocates nothing.
  • Fallback: Baseline::Counter still covers signals without a plane image (array-layout signals) and baselines loaded from a state file. Like Value → Raw, a loaded Counter becomes RawCounter at its first check.
  • State files: a RawCounter saves as the same BaselineRecord::Counter, byte for byte what Counter saved, so the file format is unchanged. A new test round-trips a counted wait through a state file, in 2-state and 4-state, at two points. It checks the waiters wake as in an uninterrupted run and that a loaded file re-saves identically.
  • Common path: check_waits tests the common Raw term before the general match. Without that, the extra variant cost the uncounted path about 5 Ir per check, (b1) +0.06%.

Breaking: celox_runtime::timing::Baseline gains a variant, hence perf(runtime)!.

Performance

Runtime Ir measured with callgrind (200k-cycle minus 20k-cycle runs, taskset), base origin/master 3766461 vs this branch:

Gate base branch Δ
(a) 64 always_ff lanes 1,180,620,062 1,180,620,048 -0.000%
(b1) + blocking stimulus kernel 1,557,900,020 1,557,720,037 -0.012%
(b5) + nonblocking stimulus kernel 1,690,740,016 1,690,560,033 -0.011%
(c) + watched always_comb pulse 3,160,224,331 2,306,876,254 -27.00%
(cs) + watched always @* pulse 3,163,499,978 2,308,458,965 -27.03%
(w) #1783 worst case 2,826,360,020 2,820,240,011 -0.22%

(c) and (cs) drop by about 4,740 Ir per cycle. Both are now well below where (cs) was before. Compile time is unchanged (no SIR change).

Validation

A wait term on a counted signal kept the signal's value at the last
check as a pair of BigUints: every check read the signal into new
BigUints and compared them. Like an uncounted plain signal, it now keeps
the signal's plane image (Baseline::RawCounter) and compares it with the
state in place. Counter remains for signals without a plane image and
for baselines loaded from a state file, which become RawCounter at their
first check; a RawCounter saves as the same Counter record.

BREAKING CHANGE: celox_runtime::timing::Baseline has a new variant,
RawCounter.

Change-Id: Icaf42a4570d829af240927beaeafcb3642cf245b
Change-Id: I1a6d04d2baedc95cd44502fe1d7c769680f54ec2
@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-23T05:13:02.845086Z dcebf33 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.

@mergify

mergify Bot commented Oct 23, 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 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 31 minutes 18 seconds in the queue, including 1 hour 11 minutes 20 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 27f96bc into master Oct 23, 2026
30 checks passed
@mergify
mergify Bot deleted the feature/perf/wait-counter-baseline branch October 23, 2026 07:45
@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