Skip to content

perf(sv): instrument each unit once for all probes - #2000

Merged
mergify[bot] merged 1 commit into
masterfrom
perf/1991-instrument-once
Oct 25, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
perf/1991-instrument-once

Conversation

@tignear

@tignear tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Closes #1991.

Summary

The probe instrumentation in assembly.rs called instrument_unit once per probe over every process kernel and every flip-flop unit. Each call rescanned the unit's instructions and its whole register_map to find the next free register. That is O(probes × program size), and it is most of the C906 frontend time now. The counted-signal loop for flip-flop evaluations that may store a signal twice had the same shape (one pass per signal).

The new watch::instrument_writes_in_passes produces exactly what one instrument_writes call per pass would produce, in a single walk over the unit:

  • watch_for(instruction, after) names the first pass from after on that watches the write. The code a pass adds is examined again by the later passes only, so a write watched by several passes is nested the same way, and a counter store matching a later pass is also handled.
  • next_register is computed once per unit. The new registers are then renumbered in the order the passes one after another would allocate them (pass, then block in map order, then position), so the instrumented units are identical, register ids included.

In assembly.rs, each probe p is pass 2p over the stable state and pass 2p + 1 over a flip-flop evaluation's working state. That matches the old loop's order, where all stable instrumentation for a probe ran before its working-state instrumentation. The probes are looked up by written address, using a binary search over each signal's probe indices. The counted-signal loop now runs one pass per signal in signal order. The instrument_stores helper is no longer used and is removed.

Tests

  • instrumenting_in_passes_matches_one_pass_after_another: on 3000 generated units, it compares the result against the per-pass instrument_writes loop with assert_eq! on the whole ExecutionUnit (blocks, instructions, register map). The units have several blocks, stores at different offsets, commits, and bit and logic values. Passes can be store-only or any-write, and their counters may be written by other passes. A mutation that renumbers by block before pass makes the test fail.
  • Affected tests with the systemverilog feature (see below).

Per the decision for complexity-order fixes, no timing comparison was run.

Local run (--features systemverilog): systemverilog 4974 passed, plus celox-frontend-core, celox-frontend-sv, frontend_sdk, processes, edge_api, ff_event_snapshot, sv_update_events, sv_untimed_processes and sv_scheduled_startup, all passed.

@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 🔄 Running since 2026-10-25T12:18:50.269745Z f8985cf 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

  • ✅ Entered queue — 2026-10-25 12:01 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • 🚫 Left the queue — 2026-10-25 12:11 UTC · at 295fd8a30388448aa62803439006f7165b1a0650

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

Reason

Pull request #2000 has been dequeued

Queue conditions are not satisfied:

  • -conflict

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, 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.

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

@mergify mergify Bot added dequeued Mergify stopped this queue entry; investigate before retrying and removed queued Mergify queue entry labels Oct 25, 2026
Closes #1991

Change-Id: Ied3fc477003f360c2ea17b71e19b6fd1a4559abb
@tignear
tignear force-pushed the perf/1991-instrument-once branch from 295fd8a to f8985cf Compare October 25, 2026 12:18
@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 1 hour 45 minutes 39 seconds in the queue, including 1 hour 6 minutes 39 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

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(sv): every probe re-instruments every unit

1 participant