Skip to content

Conversation

@anlsh
Copy link

@anlsh anlsh commented Nov 30, 2025

I've set up my filesystem such that MelonDS saves to a network filesystem, which is handy for backup purposes. Unfortunately, this causes a noticeable pause while the file is (slowly) written out.

So do the file write in the qt thread instead: this way the emulator can resume ASAP.

I do see that I've violated CONTRIBUTING.md by using std::ofstream but... is that a big deal?

I've set up my filesystem such that MelonDS saves to a network
filesystem, which is handy for backup purposes. Unfortunately, this
causes a noticeable pause while the file is (slowly) written out.

So do the file write in the qt thread instead: this way the emulator can
resume ASAP.

Signed-off-by: Anish Moorthy <anish@12rocks.io>
@Arisotura
Copy link
Member

I think the idea of saving stuff on a separate thread is worth looking into (for situations like yours), however, not sure about your approach...

@anlsh
Copy link
Author

anlsh commented Dec 22, 2025

however, not sure about your approach...

Why?

@asiekierka
Copy link
Contributor

Wouldn't this lead to a situation where the emulator is writing to the very data being placed in the save state, potentially leading to a corrupted state (say, if the emulation thread changed console RAM or CPU registers while the save method is running in the Qt thread)?

@anlsh
Copy link
Author

anlsh commented Dec 27, 2025

The emulator is still paused paused while the state is serialized to a buffer- it's just that the serialization of the buffer to the file no longer blocks the emulator from resuming. I don't believe that the emulator reuses the buffer in question for anything else, so there's no data race to speak of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants