How we built rollback netcode for PlayStation 2 on Frame Perfect
Published
Rollback netcode is now the standard for online fighting games: the game doesn't wait for your opponent's input, it predicts it and, when the prediction is wrong, rewinds, corrects and re-simulates the frames before showing the next one. On arcade boards and the PS1 this was within reach because the machines are small. The PlayStation 2 is another story. Frame Perfect has run PS2 rollback in real matches since November 2026, becoming the first fighting game platform with rollback for the console. This is how we did it.
Timeline
| Date | Milestone |
|---|---|
| Nov 1, 2026 | First PS2 rollback working on Frame Perfect: first sync tests with zero desyncs |
| Nov 2, 2026 | First online PS2 tests between two different networks (beta) |
| Nov 3, 2026 | First complete Naruto Accel 2 matches in the lobby, with ranked play in testing (beta) |
| Nov 4, 2026 | Live spectating and replays for PS2 matches (beta) |
| Nov 11, 2026 | Tekken 5, Street Fighter EX3 and Dragon Ball Z: Budokai Tenkaichi 3 (beta) |
| Nov 15, 2026 | PS2 opened to all players, with ranked play for Naruto Accel 2 |
Where we started
Frame Perfect's PS2 emulator (fp5ps2) is based on PCSX2 2.8.2, with our own shell on top: the launcher integration, networking, controllers and replays. For rollback we use GGPO (MIT license), the library that popularized the technique, with a few patches of our own.
GGPO asks the emulator for three things:
- Save the whole game state;
- Load a saved state;
- Advance one frame with the inputs it provides.
In the normal loop, each frame is: read the local input, sync with GGPO, emulate one frame up to the start of vertical retrace (the same point as PCSX2's frame advance) and tell GGPO the frame advanced. When an input arrives that contradicts the prediction, GGPO asks to load the right frame and re-run up to the present, all inside the same 16.7 ms tick (59.94 Hz for the Japanese Naruto Accel 2).
In numbers: re-running 8 frames has to fit in about 48 ms for the game to keep its pace. That was the whole challenge.
Problem 1: the PS2 state is huge
A full PS2 state is 42,355,844 bytes:
- 32 MB of Emotion Engine RAM (the main CPU);
- 2 MB of IOP RAM (the I/O processor, the "PS1 inside the PS2");
- 2 MB of sound RAM (SPU2);
- 4 MB of GS video memory, plus registers;
- both vector units (VU0 and VU1), with their memory and microprograms;
- and the internal state of dozens of parts: FPU, COP0, TLB, timers, DMA, VIF, GIF, SIF, IPU, scratchpad, CDVD, SIO.
In the first working version (Phase A, still with the European Naruto at 50 Hz), save and load used PCSX2's standard path. On the 5700X:
| average | p99 | |
|---|---|---|
| normal frame | 9.9 ms | 21.4 ms |
| 4-frame rollback | 63.7 ms | 86.9 ms |
| 8-frame rollback | 102.3 ms | 144.0 ms |
It worked, but an 8-frame rollback took more than six frames. We needed an order of magnitude.
Everything in memory, nothing allocated mid-fight
The first step was taking the disk and compression out of the way. States go straight to memory, in a 16-slot ring, each slot the size of a state plus 4 MB of headroom, allocated before the match starts (about 2.1 GB). Nothing is allocated during the fight. GGPO only keeps a pointer to the slot.
Another detail: when GGPO re-runs several frames, only the first one needs saving. The next ones, if needed later, are re-run from the previous saved state.
Fast load: keep the recompiler
PCSX2 runs PS2 code through recompilers (JIT): it translates blocks of EE, IOP and VU code into x86 code and keeps the result. The standard savestate load throws all that translated code away. That's safe, but expensive: on the next frame everything has to be translated again.
We built a fast load that keeps the translated code and only throws away code on memory pages the state changed. The full load is still there, only for the match's opening state.
Load went from 57.6 ms to 3.0 ms in Phase A, and later to about 0.15 ms.
Save only what changed
In a fight frame, the game writes to a small fraction of its 34 MB of RAM. We now mark dirty 4 KB pages of EE and IOP RAM on every write path: JIT-generated code, writes done by the emulator itself in C++, and DMA transfers. SPU2 RAM is incremental too.
Save went from about 4.1 to 2.1 ms, and load from about 2.8 to 0.9 ms.
Graphics that don't start from scratch
Each rollback reloads GS video memory, and the software renderer cleared its texture cache on every load. In practice, about 10 ms of each rollback was the EE waiting for the GS to rebuild textures that, for the most part, hadn't changed.
Now, on fast load, the GS compares VRAM in 8 KB blocks and only invalidates the ones that changed. We also load the GS in parallel with the EE, and save re-simulated frames without waiting for the GS to finish.
1-frame rollback: 22.1 → 18.4 ms.
Where we ended up
With Naruto Accel 2 (NTSC, 59.94 Hz), on the same 5700X, averages from November 6:
| average | |
|---|---|
| normal frame | 6.9 ms |
| load | 0.15 ms |
| 1-frame rollback | 16.1 ms |
| 4-frame rollback | 21.9 ms |
| 8-frame rollback | 33.8 ms |
The 8-frame rollback dropped from 102 ms to 34 ms, within the 48 ms budget.
In production, in matches between real players, that means 4 to 6 stable rollback frames on mid-range computers and 6 to 8 on high-end ones, depending on the game.
Problem 2: both sides must see the same fight
Rollback only works if the emulator is deterministic: given the same state and the same inputs, the result must be identical, byte for byte, on any machine and after any number of loads. Emulators are rarely written with that in mind.
The sync test
We built a synctest: the emulator runs the match and, every frame, rewinds and re-runs several frames, comparing a hash (XXH3) of the whole state with the first pass. Any difference points to the frame and the part of the state that diverged.
The first runs failed everywhere. There were nine core fixes, among them:
- timers recomputed on load instead of coming from the state;
- recompiler and IOP event variables (
cpuBlockCycles,intLastBranchTo,iopEventAction) that weren't serialized; - the EE and IOP JIT's "fixed blocks", the main culprit: translated code depended on history, not just on state;
- a bug in the recompiler's RAM copy (
recRAMCopy); - the SPU2 ADPCM cache, and a buffer pointer that became an index;
- unused bits in the GIF path, now zeroed;
- an instruction in a delay slot that crossed a memory page.
Then came two thread races on load (the VU thread and the disc reader) and a leak of about 2.2 MB per load.
Result: 6,000 frames with 47,944 re-simulated frames and zero desyncs, and frame 6,000 identical byte for byte across different processes. Intel and AMD produce the same 1,000 hashes in a row.
During the match
During online play, the game checks that both sides are still identical and warns when they are not.
What is drawn on screen can vary between graphics cards without changing the fight. That let us offer GPU rendering (Direct3D 11) as a launcher option, besides CPU rendering. We measured, game by game, whether the GPU image ever gets back into game memory: in Naruto, SF EX3 and Tekken 5 the fight never reads the screen. Dragon Ball Z: Budokai Tenkaichi 3 copies the screen for a transition effect, so it always runs on the CPU.
Networking
- Small inputs: each frame carries only a few bytes per player.
- GGPO prediction: compares only the button bytes, with a maximum prediction of 8 frames.
- Same game on both sides: the ISO is verified before the match, and both sides need the same core version.
- Replays and live spectating: player 1 streams only confirmed frames, 8 bytes per frame (about 44 KB for a 90-second match). Late viewers start from save points sent during the match.
Sound
Re-running frames must not replay sound. Re-simulated frames are muted, and only the "real" frame plays. Output goes through a time-stretcher (20 ms sequence, 10 ms seek, 5 ms overlap) with a 50 ms buffer that absorbs the longer tick of a rollback without crackling.
What's next
- Measure again on weaker computers with NTSC games and publish minimum requirements per game.
- Match counters (how many rollbacks, where they come from, how far the clock fell behind) to tune each game.
- A profile of the GS thread, today the biggest remaining rollback cost.
- More PS2 games (the community votes on Discord).
Credits
- PCSX2 (GPL-3.0), the base of the PS2 core. The source code with Frame Perfect's changes ships with the 64-bit Windows installer, along with the license.
- GGPO (MIT), the rollback library.
- The players who tested the first online matches and sent their logs.
Play at frameperfect.cc and join our Discord.