Dolphin, the GameCube and Wii emulator - Forums

Full Version: [PATCH] Instant GC MemCard Directory Persists
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I've recently been using Dolphin for in-home streaming and have loved it. It has run beautifully for the games I wanted to play.

There has been one issue however, when using a directory for GC memcard it will only persist the saves to the file system upon a normal closing of the application (or quitting of the game). However, while using in-home streaming I use the steam big picture in-game interface to exit the game. The way this works (at least on Linux) is that it kills the process abruptly and thus the save data is lost.

This patch I wrote forces the save file to be persisted to disk every time a write occurs to solve this problem.

I haven't tested it too extensively but it seems to work fine for Super Smash Bros Melee and Mario Party 4. I haven't noticed any performance hit on my system, but I would expect there to be slowdowns in some instances on systems running on slow storage.
I think this is a good thing to add; when Dolphin crashes, I've lost save data too. PM LPFaint99; he'll probably comment on it.
looks like it will do the right thing, the biggest issue with it is it flushes after every write (128 bytes iirc) which is 64 writes per block,
which seems ok because most saves are small, but at the same time, the whole save is rewritten to disk, so it would be better at this point to memory map the files and write to them directly.
so say an average save is 10 blocks the whole save is written to disc 640 times.

Ideally though, the flush only occurs after writing has completed, or at the very least, after each block, even checking every 15 seconds like raw memorycard would be good


it should be noted that originally flushing the memcard directory was handled by the exi_memorycard class changed by https://github.com/dolphin-emu/dolphin/c...bb49de678c
(12-01-2014, 11:02 AM)LPFaint99 Wrote: [ -> ]looks like it will do the right thing, the biggest issue with it is it flushes after every write (128 bytes iirc) which is 64 writes per block,
which seems ok because most saves are small, but at the same time, the whole save is rewritten to disk, so it would be better at this point to memory map the files and write to them directly.
so say an average save is 10 blocks the whole save is written to disc 640 times.

Ideally though, the flush only occurs after writing has completed, or at the very least, after each block, even checking every 15 seconds like raw memorycard would be good


it should be noted that originally flushing the memcard directory was handled by the exi_memorycard class changed by https://github.com/dolphin-emu/dolphin/c...bb49de678c

It seems to me that memory mapping the files would be preferable. Like you said this fixes the save file being rewritten way too many times. It also ensures the writes happen as soon as they happen in game which is much more user-friendly so that you know when the game stops saying "saving" you know it's saved and the process can be safely killed. Rather than, if you have the polling thread you have to wait 15 seconds (or whatever the interval is) after it stops saying "saving" to know the changes have been persisted to the filesystem.

Although, perhaps a configuration option would be useful to allow people to choose between memory mapped and polling for instances where memory mapped saves might be the bottleneck.