mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-22 10:50:15 -10:00
A save over a slot first reads the file there into the undo buffer, so Undo Save State can put it back. That read went through rzip: on every save over a compressed slot the old state was inflated in full, and kept inflated in memory for the rest of the session. Undo then wrote it back through rzip, deflated afresh, compressed or not as the setting had since become rather than as the file was. The backup is now the file's own bytes, read plainly, and undo writes them back as they are. Nothing is inflated on a save, nothing deflated on undo, the buffer held for undo is the file's size rather than the state's, and the slot comes back byte for byte. An 8 MiB state that compresses to 4 MiB: 2.1 -> 0.6 ms for the backup on every save over the slot, 12.4 -> 3.3 ms for the undo, and 4 MiB less held for it. At 32 MiB: 9.9 -> 3.8 ms and 41.6 -> 25.3 ms. save_state_io_test gains an RZIP=1 build with HAVE_COMPRESSION, as the frontend ships it, where every lane also passes, and a lane that saves over a slot with the compression setting turned in between, both ways, then undoes: the slot must come back byte for byte. It fails on the previous tree. Linux-samples-tasks runs that build under ASan.