Files
ppsspp/Core
Henrik RydgårdandClaude Opus 5.5 821fd301e6 SaveState: Compress and write savestates on a worker thread
Saving and loading stalled the emu thread for 30-75 ms, long enough to
glitch audio. Now only the snapshot and the apply run there; compression
and file I/O run on a savestate worker thread, in order.

- Save: snapshot in Process(), then compress, write and (for a slot) move
  the old state to its undo name on the worker. The callback runs once the
  file is written. Saving again to a path with a save pending is a repeat
  key press, and gets that save's result without a message.
- Load: read and decompress on the worker while the game runs, then apply.
  A slot load keeps the state it replaces for load undo at that point,
  rather than saving it in full before starting.
- Rewind: compression and decoding are worker jobs, and the deltas get
  zstd level 1 on top, which makes them about a third of the size.
- At most two save snapshots are in memory at once, and buffers are freed
  when their operation is done.
- Shutdown waits for pending writes, and drops callbacks as before.

On desktop, a save now costs the emu thread 2-3 ms, a load or rewind
12-15 ms.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 18:43:27 +02:00
..
…
…
…