Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raw memcards: revert last change so flushes are still time-driven. #979

Merged
merged 1 commit into from
Sep 6, 2014
Merged

raw memcards: revert last change so flushes are still time-driven. #979

merged 1 commit into from
Sep 6, 2014

Conversation

shuffle2
Copy link
Contributor

@shuffle2 shuffle2 commented Sep 5, 2014

It turns out the actual slowdown was from memcpy'ing the entire memcard buffer...not synchronization overhead or the flush itself.

@shuffle2
Copy link
Contributor Author

shuffle2 commented Sep 5, 2014

I didn't see any Common:: replacement for this std::atomic usage. And, it seems straightforward...

@delroth
Copy link
Member

delroth commented Sep 5, 2014

This looks like something that should be added to Flag (with tests!). Could you try doing that?

As long as you commit to doing it, I'm fine with merging this before it's done since it's a regression.

@delroth
Copy link
Member

delroth commented Sep 5, 2014

Oh, FWIW, I haven't reviewed this yet. Give me some time and reping me every few hours until I actually do it :p It's multithreaded crap, it really needs reviews.

@shuffle2
Copy link
Contributor Author

shuffle2 commented Sep 5, 2014

Nevermind, I replaced it with existing Common::Flag code.

@@ -78,10 +67,21 @@ void MemoryCard::FlushThread()
Common::SetCurrentThreadName(
StringFromFormat("Memcard%x-Flush", card_index).c_str());

const auto flush_interval = std::chrono::seconds(15);

for (;;)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@delroth
Copy link
Member

delroth commented Sep 5, 2014

I really don't like the fact that we lock on IO in emulation code. This is basically as bad as having IO the emulation thread. Any way to get around that?

@shuffle2
Copy link
Contributor Author

shuffle2 commented Sep 5, 2014

@delroth now lock is around copy to temp buffer.

{
std::unique_lock<std::mutex> l(m_flush_mutex);
memcpy(&m_memcard_data[destaddress], srcaddress, length);
MakeDirty();

This comment was marked as off-topic.

@shuffle2
Copy link
Contributor Author

shuffle2 commented Sep 5, 2014

popped dirty setting out of the lock.

@delroth
Copy link
Member

delroth commented Sep 5, 2014

LGTM, please merge as soon as @JMC47 has confirmed it works fine.

@nickpelone
Copy link

I can also confirm that this change (applied to master as a git patch) successfully fixed the issue.
Edit: Issue 7621 https://code.google.com/p/dolphin-emu/issues/detail?id=7621

@JMC47
Copy link
Contributor

JMC47 commented Sep 6, 2014

I checked this out and didn't notice any issues with GCI-folders or raw memcards. Tested Wind Waker, Melee and Mario Kart.

@nickpelone
Copy link

Actually, I need to take that back. My original comment was referencing 4b886b8
applied to master, which worked fine.
but the new one,
358123c
applied to master caused a crash to desktop after "Your save have been completed" or whatever in Paper Mario: TTYD.

System: Linux 3.16.1, Linux Mint 17
Architecture: amd64
Graphics Backend: OpenGL
Audio Backend: DSP HLE
Game: G8ME01 Paper Mario: The Thousand-Year Door

@shuffle2
Copy link
Contributor Author

shuffle2 commented Sep 6, 2014

can you check the backtrace to make sure it's related to this commit.

@nickpelone
Copy link

Would the backtrace have been printed to console, or are those dumped to files?

@nickpelone
Copy link

Okay I was able to reproduce it, it's a segmentation fault (all that's returned to console) that occurs when (I imagine) the save is being flushed to disk. Right before you expect the message to come up on the OSD.

@shuffle2
Copy link
Contributor Author

shuffle2 commented Sep 6, 2014

sigh...found it...really stupid mistake

@nickpelone
Copy link

Glad I could help you find it.

It turns out the actual slowdown was from memcpy'ing the entire
memcard buffer...not synchronization overhead or the flush itself.
@nickpelone
Copy link

Appears 96d7b64 works correctly. Although I will note in my first test the OSD appeared very quickly. On the second test, I noticed the OSD took a few seconds to pop up. I don't entirely know the relevance.

First test: Ran dolphin from commandline and selected game
Second test: Ran dolphin with a -e flag to my Paper Mario: TTYD dump from Steam Big Picture. (may have something to do with it)

@nickpelone
Copy link

Ultimately though, so long as the OSD about writing to disk isn't 'lying' if you would, I'd call this fixed. That's my personal opinion though so obviously y'all do what you need to.

shuffle2 added a commit that referenced this pull request Sep 6, 2014
raw memcards: revert last change so flushes are still time-driven.
@shuffle2 shuffle2 merged commit a831121 into dolphin-emu:master Sep 6, 2014
@shuffle2 shuffle2 deleted the fix-memcard-flush3 branch September 6, 2014 20:24
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants