# Status **Forked 2026-11-26** from sega32x-rust `5b1bd11` (remote `upstream`, the local checkout), which transcribes sega32x-python `0553957`. sega32x-rust's own status (its rungs' history, the /TIME fix, the reference's repin) is `git show 5b1bd11:docs/status.md`; this file is the fork's. Tier `x-rust-fast`: what is proved is "the same board as sega32x-rust", by byte-identical traces; nothing here is a hardware claim. Every number was measured on 2026-11-26 on the shared i9-13900K in the quiet window: A/B runs on CPU 28 (an E-core), the builds and the ladder on CPUs 24-27, the load average beside each. ## The ladder (`scripts/ladder.sh`) | Rung | Command | Count | | --- | --- | --- | | 0 | `scripts/external.sh --check`; the builds; `cargo test --release` | the trees at their revisions; tests pass (rung 2: upstream's 6,000 unit calls replayed, `tests/units.rs`) | | 1, ADEN = 0 | `python3 scripts/passive.py` (300 frames a case; `--full` for all) | **87 of 87** of megadrive-rust's cases byte-identical three ways (megadrive-rust `ef621e6`'s `md-trace`, megadrive-rust-fast `sockets-32x`'s, and this board's passive 32X; 81 with the passive 32X). Not run at full length in the fork | | 3, whole machine | `python3 scripts/lockstep.py` | **21 of 21** against sega32x-python's cached traces (16,360 frames, the SH-2 bus CRCs for the first 1,590) | | 3b, the benchmark | `python3 scripts/lockstep.py --against-base --cases scripts/speed-cases.tsv` | **5 of 5** against sega32x-rust `5b1bd11` (external/base): Chaotix with and without the FM, VRD (USA), SWA, Doom, 900 frames each with their presses | | 4, save states | `python3 scripts/state_rung.py` | **21 of 21** through three save states each | | 5, faults | `FAULTS=1 scripts/ladder.sh` | **not rerun in the fork** (upstream's 31 of 34 at `5b1bd11`; the faults patch upstream's lines, which only the not-kept steps touched) | The ladder takes about 17 minutes at load 15-26 with JOBS=4 (rung 3 and 4's 21 cases twice, the 87 cases three times cut to 300 frames, 3b's five cases). Found on the way, upstream's too: `scripts/ladder.sh` runs each rung through `| tail -1` under `set -eu` without `pipefail`, so a failing rung prints its count and the ladder goes on to "ladder passed". Fixed here (`14339ee`); a request for sega32x-rust. ## Steps Each kept step passed the ladder before it was kept; `ab.sh` (3 rounds, CPU 28, both layouts; per workload Chaotix, VRD, SWA, Doom). Rung 1 at full length (`--full`, every case at its length) at `28e2132`: **87 of 87** (81 passive). | Step | Commit | Kept? | default | nf5 | Load | | --- | --- | --- | ---: | ---: | --- | | 1. The -fast dependencies: megadrive-rust-fast (m68000-rust-fast, z80-rust-fast inside it) and sh2-rust-fast, no board change | `4c76ba0` | yes | **x1.082** (Chaotix x1.033, VRD x1.104, SWA x1.100, Doom x1.090) | **x1.123** (x1.054, x1.167, x1.168, x1.105) | 14-27 | | 2. The slot's call and its claims question under one lock | `ab481bd` (branch `dev`) | no | x1.018 | x0.995 | 21-28 | | 3. The SH-2 pair's catch-up: a chip stepped while the loop would pick it again | `68f845e` (branch `dev`) | no | x0.993 (nf5 not run) | | 16-21 | | 4. Release profile: codegen-units = 1, fat LTO (megadrive-rust-fast's) | `e955a3c` (measured as `1603d31` over `68f845e`) | yes | **x1.056** (x1.051, x1.077, x1.029, x1.070) | **x1.057** (x1.051, x1.070, x1.050, x1.057) | 11-17 | | 5. megadrive-rust-fast `pin-2-od2` `e153a84` merged into `sockets-32x` (`07fc04d`: `z80_offsets`' slice read) | `28e2132` | yes (a pin move; it also pays) | x1.006 (x1.011, x1.039, x0.985, x0.993) | x1.017 (x1.011, x1.039, x1.000, x1.021) | 10-15 | | 6. sh2-rust-fast: the timers' power-of-two `div_euclid` as a shift (branch `board-context-div`, `1e59923`) | not pinned | no (at most x1.01; one run lost) | x0.989, then x1.008 | x1.038, then x1.012 | 13-22 | Steps 2 and 3 are in docs/not-kept.md. Step 4 was measured on top of steps 2 and 3 (the `dev` branch) and cherry-picked onto main without them; the whole chain is measured against the fork point in the speed table below. Steps 5 and 6 are dependency changes, measured with `BIN_A`/`BIN_B` (the same board source, two dependency trees). ## Speed table (2026-11-26, at `28e2132`) `scripts/ab.sh 5b1bd11` with `LAYOUTS=default`, the five workloads of `scripts/bench.sh` (900 frames from power-on, start pressed, sound and picture taken every frame), best of 3 alternating runs on CPU 28 (an E-core), load 12-19, the checks identical on both sides. Before is sega32x-rust `5b1bd11` as upstream pins it; after is this fork. Real time is 60 frames a second (all five are NTSC). | Cartridge | sega32x-rust | sega32x-rust-fast | Speed-up | | --- | ---: | ---: | ---: | | Knuckles' Chaotix (FM on) | 38.5 fps (0.64x real time) | 43.6 fps (0.73x) | x1.133 | | Knuckles' Chaotix (`--no-fm`) | 38.0 fps (0.63x real time) | 43.7 fps (0.73x) | x1.152 | | Virtua Racing Deluxe (USA) | 39.6 fps (0.66x real time) | 46.7 fps (0.78x) | x1.179 | | Star Wars Arcade (USA) | 33.8 fps (0.56x real time) | 39.9 fps (0.66x) | x1.179 | | Doom (Japan, USA) | 35.7 fps (0.60x real time) | 42.4 fps (0.71x) | x1.186 | | **Total** | 121.6 s | 104.3 s | **x1.166** | The bench agent's sega32x-rust on CPU 30 (load 15-25): Chaotix 33.1, VRD 35.9, SWA 30.2, Doom 31.3 fps, consistent with the left column (its workloads differ slightly). Compare only runs on the same pinned core. ## The profile (s32x-profile, Knuckles' Chaotix, 900 frames, at `28e2132`) `s32x-profile` (megadrive-rust-fast's SIGPROF sampler; `perf` is not allowed here) and `scripts/profile.py` (with `--callers` for who a hot function's time comes through). Self time: the SH-2 core about 55 % (`pipeline::advance` 12.1 %, `core::step` 10.1 %, `issue` 4.2, `retire` 3.5, `dispatch` 3.4, the fetch and cache path about 9, the timers' `div_euclid` 3.1, `interrupt_due` 1.3); this board's catch-up loop `sh2_catch_up` 5.4 % with the `Option` look-ups it inlines (4.7 %) and `sh2_with_chip` 1.6 %; the device's mutex 3.9 %; the Mega Drive side, the 32X VDP, PWM and composite each under 1 %. Inclusive: the SH-2s' `step` about 66 %, reached from the 68000's reads of 32X space (`read_word`, 52-57 %) and the board's catch-ups (`catch_up_clocked`, 28-34 %). Doom's profile has the same shape. ## Threads (out of scope tonight; decision B5) sega32x-python docs/domains.md names four domains on one clock. What a threaded tier would need first: - **The SH-2 pair against the Mega Drive side.** Every 68000 or Z80 access to 32X space is a sync point (the SH-2s are caught up to it first), and the games poll the communication ports and registers in tight loops, so a thread per side would meet at almost every 68000 instruction. It needs the domain-boundary work: a bounded lookahead for the SH-2 pair (run ahead to the next instant the 68000 can observe, with a way to stop at a channel access) or a channel log the other side replays, and its proof against the serial order of record. - **The composite (socket 7) and PWM's sample making (socket 8)** are producers read only by the host: the cheapest first channels, each a queue of line rows or period levels. Both are under 1 % here, so they pay only once the SH-2 pair is apart. - **Inside the SH-2 pair**, the two chips share the bus, SDRAM, the frame buffer's FIFO and each other's interrupts; the charter keeps them one domain. - Already in place: the device is behind `Arc>` (console.rs), so the socket objects are `Send`; the SH-2s' ports reach the device by pointers only for a call's length. ## Next toward full speed At `28e2132` the four games run at 0.6-0.8x real time on an E-core (the speed table). The board's own code is now a small part; the SH-2 core is most of it: - **sh2-rust-fast's per-step work** (its scheduler and checks, about 37 % and 25 % of the core in its own profile): the largest lever, and that tier's (its owner's) work. The 32X's steps are short (the pair interleaves instruction by instruction), so per-step costs dominate. - **The timers' divisions** (step 6, `board-context-div`): passes sh2-rust-fast's ladder and this one's, worth at most 1 % here (docs/not-kept.md); for sh2-rust-fast to take or leave. - **Fewer calls per 68000 access** to the device (`video_first`, the access, the claims: three locks and three dispatches through the socket): a socket-protocol change in megadrive-rust (and megadrive-python first, if it is behaviour-visible; it is not). - **Idle loops**: both chips and the 68000 spend much of a frame polling; skipping a proven idle loop is turbo-tier work (every observable identical, the per-instruction path as the fallback). - **PGO** (megadrive-rust-fast's `scripts/pgo.sh`) is untried here. - HYPOTHESIS (not measured tonight: no P-core was assigned): a P-core runs this about 1.4-1.5x faster than CPU 28, judging by upstream's unpinned 49.6 fps (Chaotix, load 15-20) against the bench agent's 33.1 fps pinned to an E-core.