Skip to content

Commit

Permalink
Increase save state chunk size for all platforms
Browse files Browse the repository at this point in the history
A rationale is given in the comments, but even a class 6 or class 10 SD card can handle reads and writes on the order of MB/s, which means a 4KB chunk size is just wasting time in syscalls.  This could maybe be fixed with a buffering reader but I don't feel comfortable tweaking libretro-common's VFS to handle that.  Instead, I thought it would be good to both remove an ifdef and increase the chunk size to 128KB.  For cores with small states this will should make state saving virtually instantaneous, and for cores with large states it should be a 32x speedup.
  • Loading branch information
JoeOsborn authored and LibretroAdmin committed May 29, 2024
1 parent 3a56b73 commit 9c4ac35
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tasks/task_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@
/* Filesystem is in-memory anyway, use huge chunks since each
read/write is a possible suspend to JS code */
#define SAVE_STATE_CHUNK 4096 * 4096
#elif defined(HAVE_LIBNX) || defined(_3DS)
#define SAVE_STATE_CHUNK 4096 * 10
#else
#define SAVE_STATE_CHUNK 4096
/* A low common denominator write chunk size. On a slow
(speed class 6) SD card, we can write 6MB/s. That gives us
roughly 100KB/frame, which is rounded up to 128 KB/s.
This means we can write savestates with one syscall for cores
with less than 128KB of state. Class 10 is the standard now
even for lousy cards and supports 10MB/s, so you may prefer
to double this. */
#define SAVE_STATE_CHUNK 128 * 1024
#endif

#define RASTATE_VERSION 1
Expand Down

0 comments on commit 9c4ac35

Please sign in to comment.