The scheduler: who runs when, and for how long
The console runs its parts one after the other, each up to a time (Architecture says how). A part that is
called for short pieces costs glue at each call, whatever it runs, and a recompiler only helps a part whose calls run long: the two
recompilers that were built first lost to their interpreters mostly for that reason (how it was made). So the scheduler counts
how long its calls into each part run, and this page has the counts of four games: the baseline that the speed work is measured
against. The page is a record of that work on 2026-12-02, in its order: each section names the build that it was measured on.
The code is in crates/n64emu-core: calls.rs has the counters, and machine.rs, bus.rs and rcp.rs call the parts.
The calls
| Part | Called by | Its cycles per call |
processor | Machine::step: it runs up to the next stop (Bus::stop_at), and goes on over stops that are only the RSP's (Bus::pass_stop) | its own (93.75 MHz), by its clock before and after |
processor_held | Machine::parked: it catches up after it waited in a loop while the RSP ran | the same |
rsp_run_to | before each access of the processor, each event and each state (Bus::run_rsp_to), and back to now after it led too far (Bus::behind) | the RCP's (62.5 MHz), by the RSP's clock before and after |
rsp_run_to_call | it leads: it runs ahead up to just before its next call of the bus (Bus::lead) | the same |
rsp_run_to_signal | the processor is parked: it runs up to its next signal (Bus::run_rsp_to_signal) | the same |
rsp_halted | any of the three while it is halted. It runs no program then, and its clock does not move, so its cycles are 0 | the same |
rdp_commands | the RDP's command interface comes up to now (Rcp::run_rdp), before uses of the memory and at its event | the RCP's since its call before |
pi, si, ai, vi_line, frame_limit | their events, and the AI also where it catches up | the same |
The counters change nothing that comes out. They are in no state, read only clocks that the parts have, and decide nothing. Off, each
costs one test of an Option at a call. Checked: a test runs three programs with them on and off, with the processor parked and not, and
compares the state and sound after each frame; and a comparison of the hashes of each frame gave the same hashes as the reference build 23ec1b7 in all 900
frames of the four games below, both without --calls and with it (with --hashes, on build cbfae03, on 2026-12-02). User cycles
(perf stat -e cycles:u, 900 frames, two rounds alternating with the reference build, mean): Mario 40.47G before and 40.37G with the
counters off, GoldenEye 32.72G and 32.72G, Banjo 38.76G and 39.13G, Mario Kart 64 26.29G and 26.25G. The two rounds of one build differ
by up to 1.3%, as other programs ran at the same time, so no cost of the counters can be seen.
n64emu-dev --calls prints them at the end of a run: for each part, its calls, calls per frame and mean cycles per call (calls ...), and
how many calls fell in each power of two of cycles (calls_by_length ...). Its histogram is an n64_jit::CallStats, the type that the
recompilers count their runs in too.
The baseline (2026-12-02)
Build cbfae03 (the interpreters as they were at 23ec1b7, with the counters), 900 frames from power-on with no buttons held, the RDP on
the Arc, n64emu-dev --frames 900 --gpu Arc --calls, without --hashes (a state after each frame would add calls). Calls per frame ×
mean cycles per call:
| Part (clock) | Super Mario 64 | GoldenEye 007 | Banjo-Kazooie | Mario Kart 64 |
processor (processor) | 1,288.7 × 1,096.6 | 1,497.5 × 883.3 | 860.4 × 1,515.1 | 1,333.5 × 1,018.1 |
processor_held (processor) | 254.6 × 605.9 | 411.0 × 597.3 | 238.8 × 1,109.2 | 395.3 × 532.5 |
rsp_run_to (rcp) | 2,267.0 × 1.8 | 2,006.9 × 1.6 | 11,990.6 × 32.9 | 635.4 × 1.9 |
rsp_run_to_call (rcp) | 2,261.1 × 150.0 | 1,997.3 × 140.6 | 2,187.8 × 60.8 | 641.7 × 351.8 |
rsp_run_to_signal (rcp) | 394.9 × 261.1 | 449.8 × 364.8 | 697.6 × 253.5 | 561.1 × 250.9 |
rsp_halted (rcp) | 8,450.6 × 0 | 2,678.3 × 0 | 3,709.2 × 0 | 4,103.5 × 0 |
rdp_commands (rcp) | 1,355.3 × 771.0 | 1,397.4 × 747.7 | 745.4 × 1,402.7 | 1,079.5 × 967.2 |
pi (rcp) | 37.2 × 28,033 | 16.7 × 62,398 | 20.5 × 50,763 | 20.3 × 51,364 |
si (rcp) | 1.1 × 973,745 | 1.6 × 637,717 | 1.0 × 1,057,099 | 1.5 × 677,530 |
ai (rcp) | 6.7 × 154,887 | 4.3 × 244,783 | 4.2 × 248,823 | 6.8 × 152,713 |
vi_line (rcp) | 266.2 × 3,924.9 | 267.2 × 3,912.9 | 268.0 × 3,901.7 | 266.6 × 3,921.9 |
frame_limit (rcp) | 0.02 × 1,044,694 | 0.03 × 1,044,694 | 0.03 × 1,044,694 | 0.02 × 1,044,694 |
The share of calls by their cycles, for the parts that run programs:
| Part | Game | 0 | 1–15 | 16–255 | 256–4095 | 4096+ |
processor | Mario | 0% | 20% | 39% | 28% | 12% |
processor | GoldenEye | 1% | 27% | 40% | 21% | 11% |
processor | Banjo | 1% | 29% | 34% | 14% | 22% |
processor | MK64 | 1% | 30% | 31% | 25% | 13% |
processor_held | Mario | 0% | 1% | 55% | 41% | 2% |
processor_held | GoldenEye | 0% | 1% | 82% | 11% | 5% |
processor_held | Banjo | 0% | 1% | 64% | 20% | 15% |
processor_held | MK64 | 0% | 1% | 82% | 12% | 5% |
rsp_run_to | Mario | 14% | 86% | 0% | 0% | 0% |
rsp_run_to | GoldenEye | 14% | 86% | 0% | 0% | 0% |
rsp_run_to | Banjo | 2% | 25% | 72% | 1% | 0% |
rsp_run_to | MK64 | 9% | 91% | 0% | 0% | 0% |
rsp_run_to_call | Mario | 12% | 13% | 61% | 14% | 0% |
rsp_run_to_call | GoldenEye | 13% | 13% | 58% | 15% | 0% |
rsp_run_to_call | Banjo | 24% | 24% | 47% | 5% | 0% |
rsp_run_to_call | MK64 | 2% | 4% | 42% | 52% | 0% |
rsp_run_to_signal | Mario | 0% | 2% | 70% | 28% | 0% |
rsp_run_to_signal | GoldenEye | 0% | 2% | 82% | 16% | 0% |
rsp_run_to_signal | Banjo | 0% | 1% | 73% | 25% | 0% |
rsp_run_to_signal | MK64 | 0% | 2% | 83% | 15% | 0% |
rdp_commands | Mario | 0% | 3% | 70% | 26% | 0% |
rdp_commands | GoldenEye | 0% | 3% | 77% | 19% | 1% |
rdp_commands | Banjo | 0% | 4% | 80% | 15% | 1% |
rdp_commands | MK64 | 0% | 1% | 69% | 29% | 2% |
A frame has about 1.56 million of the processor's cycles and 1.04 million of the RCP's. The command above prints every power of two.
What it says
- The RSP runs in short calls. Its program runs mostly in
rsp_run_to_call (it leads up to its next call of the bus) and
rsp_run_to_signal: 60 to 350 cycles a call on average, and in Mario, GoldenEye and Banjo a quarter to a half of the leads run under
16 cycles. Each lead ends at the RSP's next access of something outside (its DMA, the RDP's registers, its status), so a call is as long
as the stretch of its program between two such accesses, not as long as the scheduler would let it run (up to 16,384 cycles).
rsp_run_to comes up to now before the processor's accesses: about 2,000 calls a frame of 1 or 2 cycles each, and in Banjo 12,000 of
about 33. A recompiled RSP whose calls end where the interpreter's do would spend these short pieces in the glue of each call, as
its first recompiler did; it has to go on over its own accesses (as calls into Rust) and leave only where the console has to see it.
- The RSP was called 2,700 to 8,500 times a frame while it was halted, which runs nothing (
rsp_halted). It is not any more: see
the idle RSP.
- The processor's calls run about 900 to 1,500 cycles on average, but 20 to 30% of them run fewer than 16: stops that come right after
another (the RDP's full syncs, a line of the picture, the RSP's signals). The long ones (4096 and up, 11 to 22% of the calls) have at least
46 to 59% of its cycles.
- The RDP's command interface comes up to now about 750 to 1,400 times a frame, mostly 16 to 255 cycles after its call before.
Why calls end (2026-12-02)
n64emu-dev --calls also prints what ended each call of the processor and of the RSP's program (calls_ended PART short N long M REASON), apart for calls under 16 cycles (short) and the others (long). calls.rs says how each reason is found:
- The processor's run ends at the first event in the scheduler's list when it returns. The RSP's event is its next call of the bus
while it leads, and its next signal otherwise. "(it waits)": the processor was in a loop that waits then.
rsp_run_to ends at the time that its caller asked for: an access of the processor (by what it reaches), an event, a catch-up, or
the way back after a lead was undone (by what undid it).
- A lead (
rsp_run_to_call) ends at the end of its window, or just before the RSP's next call of the bus, which is seen when the RSP
makes it (its kind, and for the RDP's registers which one). A lead that is undone first is "given up", with what undid it. When the
RSP's next call comes later than the cycle after the lead's end, "no call at its end".
rsp_run_to_signal ends at its bound, or right after its own signal (a write of the RDP's registers or its interrupt), which it
makes inside the call. (Until 37666c4, the counters looked for that signal after the call, and called these "no call at its end".)
Build d4252b0, the same runs as the baseline (900 frames, no --hashes). Calls per frame, under 16 cycles / 16 or more; rows under
half a call per frame are left out (among them, a lead reached the end of its window 0 to 0.04 times a frame, and was given up 0 to 0.8
times):
processor: calls per frame, under 16 cycles / 16 or more
| What ended it | Mario | GoldenEye | Banjo | MK64 |
| event: the RDP's full sync (it waits) | 226 / 75 | 358 / 191 | 191 / 24 | 349 / 281 |
| event: the RSP's next call of the bus (it leads) (it waits) | 5 / 249 | 5 / 405 | 8 / 225 | 7 / 384 |
| event: the RDP's full sync | 6 / 422 | 3 / 250 | 1 / 116 | 0 / 19 |
| event: a line of the picture (it waits) | 29 / 91 | 55 / 152 | 48 / 54 | 49 / 167 |
| event: a line of the picture | 2 / 144 | 1 / 59 | 1 / 165 | 0 / 50 |
| event: PI | 1 / 22 | 0 / 12 | 0 / 13 | 0 / 13 |
| event: PI (it waits) | 0 / 14 | 0 / 4 | 0 / 7 | 0 / 6 |
| event: the RSP's signal (it waits) | 1 / 0 | 1 / 0 | 5 / 1 | 3 / 1 |
| event: SI (it waits) | 0 / 1 | 0 / 1 | 0 / 0 | 0 / 1 |
| all | 269 / 1,019 | 423 / 1,075 | 253 / 607 | 409 / 924 |
rsp_run_to: calls per frame, under 16 cycles / 16 or more
| What ended it | Mario | GoldenEye | Banjo | MK64 |
| access: RDRAM | 4 / 0 | 7 / 1 | 609 / 8,580 | 3 / 0 |
| event: the RSP | 2,026 / 1 | 1,624 / 1 | 2,411 / 1 | 268 / 0 |
| event: the RDP's full sync | 226 / 0 | 357 / 0 | 191 / 0 | 348 / 0 |
| event: a line of the picture | 10 / 0 | 18 / 0 | 50 / 64 | 16 / 0 |
| access: MI, VI, AI, PI, RI or SI | 0 / 0 | 0 / 0 | 15 / 64 | 0 / 0 |
| event: PI | 0 / 0 | 0 / 0 | 1 / 2 | 0 / 0 |
| all | 2,265 / 2 | 2,005 / 2 | 3,277 / 8,714 | 634 / 1 |
rsp_run_to_call: calls per frame, under 16 cycles / 16 or more
| What ended it | Mario | GoldenEye | Banjo | MK64 |
| its call: reads DPC_STATUS | 1 / 440 | 1 / 597 | 305 / 373 | 3 / 349 |
| its call: a row of its DMA starts | 2 / 666 | 3 / 465 | 4 / 401 | 2 / 146 |
| its call: reads DPC_CURRENT | 281 / 0 | 259 / 0 | 527 / 0 | 14 / 0 |
| its call: a row of its DMA is written | 2 / 345 | 2 / 300 | 2 / 248 | 2 / 46 |
| its call: writes DPC_END | 280 / 0 | 258 / 0 | 207 / 0 | 15 / 0 |
| its call: a row of its DMA is read | 1 / 241 | 1 / 110 | 1 / 117 | 0 / 62 |
| its call: raises its interrupt | 0 / 1 | 0 / 1 | 0 / 0 | 0 / 1 |
| all | 568 / 1,693 | 526 / 1,471 | 1,047 / 1,141 | 38 / 604 |
rsp_run_to_signal: calls per frame, under 16 cycles / 16 or more
| What ended it | Mario | GoldenEye | Banjo | MK64 |
| no call at its end | 5 / 337 | 5 / 378 | 6 / 629 | 8 / 491 |
| its bound | 2 / 51 | 3 / 63 | 3 / 59 | 3 / 59 |
| all | 7 / 388 | 9 / 441 | 9 / 689 | 11 / 550 |
What it says
- The RSP's leads end at its own calls of the bus, nearly never at their window. Long leads end before it reads DPC_STATUS (a loop
that waits for the RDP), before a row of its DMA, and before it raises its interrupt. The short ones (under 16 cycles; 530 to 1,050 a
frame in Mario, GoldenEye and Banjo, and 40 in Mario Kart 64) end mostly at the RSP's work with the RDP's registers: reads of
DPC_CURRENT, writes of DPC_END and DPC_START, reads of DPC_END and writes of DPC_STATUS, and in Banjo also reads of DPC_STATUS. Each is a lead of a few cycles, then a catch-up of 1 or 2 cycles to make
the call (
rsp_run_to "event: the RSP", 270 to 2,400 a frame).
- The processor's short runs are mostly in a loop that waits, ended by the RDP's full sync (190 to 360 a frame). Its run ends at
the next full sync that the RDP's command interface finds ahead, which comes again a few cycles later, while the processor is not
parked (it is parked only for the RSP's stops). Each such stop also brings the RSP up to it (
rsp_run_to "event: the RDP's full
sync", the same number, all short).
- In Banjo-Kazooie the RSP runs mostly by the processor's accesses to RDRAM (9,200 a frame, most of 16 to 255 cycles). Its leads are
short there (48% under 16 cycles), so leading is skipped for a while after four short ones in a row (
SKIPPED_LEADS).
rsp_run_to_signal mostly ends right after the RSP writes DPC_END (340 to 640 a frame, of 390 to 700): the table above calls
these "no call at its end", which was wrong (see the reasons above).
The idle RSP
While the RSP is halted and nothing of it happens by itself (Rsp::next_event is None), it is not run for the processor's accesses
to anything but itself and the RDP's registers, nor for events (Bus::run_rsp_to, rsp_idle). n64-rsp's run_to gives the same result
in any pieces, and its next_event is None until something is written to it (its public docs), so the next run that is needed gives the
same: before the processor uses its memories or registers or writes the RDP's registers, after a lead, at the end of a frame, and before a
state. Only a call of the RSP can end it, and each is followed by Bus::look_at_rsp, which looks again.
Checked: a test runs four programs with it on and off, parked and not, leading and not, and compares the state and sound after each
frame. A comparison of the hashes of each frame gave the same as the reference build 23ec1b7 in all 900 frames of the four games (build 24bbd22).
The calls while it is halted fell from 2,700–8,500 a frame to about 465, nearly all of them the processor's accesses to the RSP itself.
Almost all of these are in the boot: 389,000 in the first 20 frames of Mario. No change in user cycles could be measured (perf stat -e cycles:u, 900 frames, two rounds alternating with d4252b0, mean): Mario 39.83G before and 40.50G after, GoldenEye 32.30G and 32.45G,
Banjo 39.11G and 39.80G, Mario Kart 64 26.66G and 26.05G. The two rounds of one build differ by up to 2.5%, and the differences go both
ways: the calls that it leaves out were cheap.
The design for long calls (milestone 3, 2026-12-02)
The design of the speed work asks for long calls: thousands of cycles per call of the RSP, and fewer runs of the processor. The tables above
say why they are short. Four counters were added first (37666c4, --calls), to see what each step would remove before it is built.
They count only; build 37666c4, the same 900 frames as above, per frame:
| What a step would remove | Mario | GoldenEye | Banjo | MK64 |
A waiting processor not parked at another event (processor_waits) | 436 | 761 | 324 | 855 |
| of them, its pins stay, and no frame ends | 434 | 758 | 322 | 850 |
Leads that end before a row of the RSP's DMA starts (rsp_lead_dma) | 668 | 468 | 405 | 148 |
| of them, the RDRAM channel is as at the lead's start | 212 | 146 | 153 | 31 |
Catch-ups of the RSP that the console asked for and did not need (rsp_far) | 2,266 | 2,007 | 11,989 | 635 |
of them, n64_rsp::Rsp::far_event says that it makes no call of the bus by then | 238 | 379 | 225 | 365 |
1. A waiting processor stays parked across every event that it cannot see
What it rests on: a loop that waits uses nothing of the bus (n64-vr4300's wait.rs: no access around the caches, no miss, no write
that leaves the buffer, no CACHE or TLB instruction, no read of Count or Random). So until Processor::waits_until, it sees only its
interrupt pins (the MI's line after its mask, and the reset button's warning), the PIF's NMI and freeze, and nothing else. An event that
leaves these as they were cannot change what it does, so it can happen while the processor stays behind, as the RSP's stops already
do (Machine::parked).
How: parked goes on over all events in their order with Bus::advance, not only the RSP's: an RDP full sync, a line of the picture,
the PI, SI, AI and the frame's limit. It stops, as now, at the first of: an event at or after waits_until, a change of the pins, something
for the processor from the PIF, or the end of a frame. Then run_held catches the processor up to the last event with the pins as they
were, and it goes on as usual from there. No other part sees a difference: the events happen at the same times and in the same order,
and only the processor's own run is cut otherwise. The RSP's stops inside it go on as before (run_to_signal up to the next other event).
Checked by: the tests that compare a parked processor with one that is not (Bus::parks), with the programs whose processor waits
for the RSP, the VI and the RDP; hashcmp on the four games; and --each-rsp-step against a plain run on one game. Counters: the
processor's runs per frame, and processor_waits should fall to the cases where the pins change.
Built (3281e57). hashcmp: the same as 23ec1b7 in all 900 frames of the four games; --each-rsp-step against a plain run
of the same build: the same in all 900 frames of Mario. Per frame, before (37666c4) and after:
| Mario | GoldenEye | Banjo | MK64 |
processor calls | 1,288.7 → 601.6 | 1,497.5 → 329.9 | 860.4 → 301.2 | 1,333.5 → 89.2 |
| its mean cycles per call | 1,096.6 → 1,434.8 | 883.3 → 1,056.3 | 1,515.1 → 3,222.2 | 1,018.1 → 3,344.4 |
| of them under 16 cycles | 269 → 9 | 423 → 4 | 253 → 2 | 409 → 1 |
processor_held calls | 254.6 → 3.7 | 411.0 → 4.3 | 238.8 → 3.2 | 395.3 → 5.9 |
| its mean cycles per call | 605.9 → 192,876 | 597.3 → 285,524 | 1,109.2 → 189,375 | 532.5 → 216,744 |
The RSP's calls did not change, as this step is only the processor's. No change in user cycles could be measured (perf stat -e cycles:u, two rounds alternating with 37666c4, mean): Mario 41.65G before and 42.38G after, GoldenEye 33.76G and 32.87G, Banjo
40.17G and 40.44G, Mario Kart 64 26.77G and 26.80G. One build's two rounds differ by up to 5% (Mario after: 40.72G and 44.03G), as other
agents ran at the same time. The runs that went were short ones of a loop that waits, which cost little each.
2. The RSP's lead goes on across its reads of the RDP's registers, where they are known ahead
What it rests on: Dpc::steady_until (the core's): the first time after now at which these registers could read otherwise, if only
the interface's own steps happen. It can be too early and never too late. What can make them change earlier: a write of the processor
(which undoes a lead already: Bus::behind) and a write of the RSP itself. The processor's accesses to RDRAM can only delay the
RDP's fetches (the channel is first come, first served), never bring them earlier.
How: at a lead's start, the RDP's interface is brought up to now (as before any use of the memory), and the lead is run with a bus of
its own. It answers a read of the RDP's registers at a cycle before their steady time with their value now, and dpc_steady_until with
that steady time, so that the RSP's loops that wait for the RDP are passed as when it does not lead. Every other call ends the lead
before it, as now. The lead is undone as before.
This needed two things of n64-rsp that its public interface did not have (asked of the RSP's port on 2026-12-02, and built since):
run_to_call that lets some calls through: before each call of the bus, it asks the bus whether this one may be made now (its kind,
the RDP's register for read_dpc, its cycle), and stops before it, as now, when not. For example a provided method of n64_rsp::Bus,
fn may_call_ahead(&mut self, call: CallKind, at: u64) -> bool { false }, which run_to_call asks.
rewind that stays right after such calls (read_dpc and dpc_steady_until), which change only the registers and what is found
of loops that wait. Today it is "only right if the RSP made no call of the Bus".
What is not done, and why:
- A row of the DMA cannot be timed ahead. Its time comes from the RDRAM channel, which serves whoever asks first, in the order of
the calls (
rdram.rs, a guess). While the RSP leads, the processor's accesses at earlier times have not been made yet. At only 22 to
38% of the leads that end before a row was the channel as it was at the lead's start (the table above). That is too few to guess and
undo, so a row still ends a lead.
This sets a floor on the RSP's calls: at least one for each row of its DMA, about 700 to 1,250 a frame in these games (the rows'
starts, reads and writes in the tables above), so a few hundred cycles per call while the processor runs, not thousands.
The memory's model stays as it is for now (decided on 2026-12-02). The RSP's recompiler is measured first: at a few hundred
cycles per call, the cost of a call may already be small next to compiled code (the first recompiler lost at calls of a few cycles).
If it is not, how RDRAM serves the RSP's DMA, the processor and the RDP is decided by a measurement on the owner's console, and not by
a guess chosen for speed.
- The RSP's writes of DPC_END and DPC_START are not kept for later: right after them the RDP fetches, so the reads that follow are not
steady and would end the lead at once (the short leads before reads of DPC_CURRENT follow those writes). It would remove one short
lead of each such pair, with all that undoing a kept write needs.
Built (fa30c97), with the RSP's port's n64_rsp::Bus::may_call_ahead and a rewind that stays right after these reads (5b43b13). The
core's bus answers them from Rcp::ahead (the RDP's registers and their steady times at the lead's start). hashcmp: the same as 23ec1b7
in all 900 frames of the four games, with and without the processor's recompiler of then; --each-rsp-step against a plain run of the same build: the same in all 900
frames of Banjo-Kazooie. Per frame, before (c4bcbb3) and after:
| Mario | GoldenEye | Banjo | MK64 |
rsp_run_to_call calls | 2,261 → 1,907 | 1,997 → 1,690 | 2,188 → 1,312 | 642 → 626 |
| its mean cycles per call | 150 → 178 | 141 → 167 | 61 → 406 | 352 → 362 |
rsp_run_to calls | 2,267 → 1,891 | 2,007 → 1,655 | 11,991 → 1,285 | 635 → 600 |
| leads that end before reading DPC_CURRENT | 281 → 0 | 259 → 0 | 527 → 0 | 14 → 0 |
| leads that end before reading DPC_STATUS | 441 → 351 | 598 → 518 | 678 → 277 | 352 → 318 |
User cycles (perf stat -e cycles:u, two rounds alternating with c4bcbb3, mean): Banjo-Kazooie 38.92G before and 33.68G after
(−13%; both rounds agree within 1%), Mario 40.44G and 39.73G, GoldenEye 32.52G and 31.77G, Mario Kart 64 25.43G and 25.67G (the last
three within the noise of other agents' runs). In Banjo the leads are no longer short, so they are no longer skipped, and the RSP is not
brought up at each of the processor's accesses to RDRAM any more. The leads that still end before reading DPC_STATUS read it after its
steady time (the RDP is drawing), and the short ones end before the RSP writes DPC_END, which is not done ahead.
3. Banjo-Kazooie
In Banjo-Kazooie the RSP runs mostly in catch-ups at the processor's accesses to RDRAM (9,200 a frame), as its leads are left out: after four
short leads in a row, 64 chances to lead are skipped (SHORT_LEAD, SKIPPED_LEADS). Its short leads end before reads of DPC_STATUS and
DPC_CURRENT, a loop that waits for the RDP. A catch-up at an access can only be left out where the RSP makes no call of the bus of any
kind by then (a read of the RDP's registers at an earlier time, made later, would see the interface at a later time). far_event is
such a bound, and allows only 225 of the 11,989 a frame. So the step for Banjo is step 2: leads that pass that loop are long, and
are not skipped (as measured above). No other change is planned for it; far_event is not used.
The recompilers' framework: hot lists and the dispatcher (2026-12-02)
Measured with the RSP's recompiler (n64-rsp-jit, then turned on with --rsp-jit, and on by default since) on Super Mario 64 (USA), 900 frames, --gpu Arc, user cycles
(perf stat -e cycles:u); other agents ran at the same time.
A hot list compiled at the start as whole units or as pieces (n64_jit::Jit::prepare, set_prepare_as_pieces), second runs with the
same list, three rounds alternating:
| Compiling at the start | User cycles, 900 frames |
| One whole unit per source (the default) | 2.47 to 3.86 s | 43.2G, 46.0G, 45.3G |
| Pieces, as play makes them | 1.26 to 1.37 s | 42.1G, 42.3G, 43.0G |
Pieces are entered three times as often (12.9 M entries against 4.1 M, and 10.9 M leaves against 2.2 M), so without the start they run
900 frames some 4 G cycles slower; over a longer game, whole units win, and the owner's rule is runtime over load time. So whole units stay
the default, and pieces are a setting. The directory now learns the entries of every piece of a source when one is found or made: after
each of the 6,028 changes of the microcode, all pieces are found again at once. That took the first run (pieces made in play) from 53.1G and
54.0G to 39.6G and 42.8G, and found sources again 6,020 times in place of 143,738.
The dispatcher's fixed cost. In a profile of the second run (perf record), n64_jit::Jit::run (the dispatcher, with the directory
inlined) has 1.9% of the samples and the trampoline of calls into Rust 1.6%; the RSP's front end's own work at each event (its keys,
place, its steps) is apart. Its timing test (cargo test --release -p n64-jit --test dispatch -- --ignored --nocapture): a unit's entry and
exit with a step of the interpreter took 18.2 to 18.5 ns, and 15.2 to 17.2 ns after 899f0b9: units' code in a dense array, and the engine's
check of its own units only in debug builds. A front end whose exits always give the next key says so (FrontEnd::EXIT_IS_KEY), and then
the dispatcher does not ask for the key again after an exit. On Mario's second run the difference was within the noise (44.9G before and
42.7G after, means of three rounds that differ by up to 4.0G).
Spreading the start's compiling. A hot list's keys are in the order in which they were first entered. The start could compile only
the units of the first frames' keys, and the rest between frames, a few each frame, on the core's thread. That needs the frame of each key's
first entry in the list (a new version of its bytes), and a call between frames. Not built; the first frame waits for all of it now.
What is not counted
- How long each call takes on the host, which is for a profiler (
perf). The counts here do not depend on what else the machine runs.
- The processor's and the RSP's work inside a call (instructions, waits), which their own counters have (
--rsp-counts, the waits line).
- Other games and other parts of these four: the runs start at power-on, so the first frames of each are its boot and intro.