Skip to content

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

Closed

Description

@tignear

rtlmeter C906 simulates at about 35 cycles/s on the native backend (four-state, hello: ~3,300 cycles in ~95 s after "Init Program"). xezim needs 2.5 s for the whole run. A profile of the simulation phase (perf, native, master + #2058 + #2073) shows the JIT code is not the cost:

  • 55.7% SimulationState::check_waits (crates/celox-runtime/src/simulation/wait.rs), called from continue_round → run_time / end_time
  • of which 33.7% is self time in advance (planes_equal / copy_planes on the watched signal's planes) and 19.5% is self time in check_waits

check_waits visits every waiting process and every term of its event control on every round. For each Baseline::Raw term it compares the signal's whole state planes with the last seen image. The cost per round is therefore O(waiters × bytes of their watched signals), whether anything changed or not. A suspect is event controls whose terms are whole unpacked memories (for example the implicit sensitivity of an always @* that reads mem[addr]). C906's 2^19-entry SRAM banks would then be compared byte by byte every round.

Expected

Waking waiters costs O(changed signals), not O(waiters × watched bytes):

  • terms on large or array signals use write counters or dirty marks (Baseline::Counter / RawCounter already exist) instead of full plane comparison;
  • check_waits only visits waiters whose signals were written since the last check (an index from signal to waiters).

First confirm which terms dominate on C906. The fix must not slow down designs with few waiters (b2 callgrind gate).

Activity

  1. added a commit that references this issue on Oct 26, 2026
    c42418d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions