Page 1 of 1

[path] performance bugfix

Posted: Thu 08 Feb, 2018 6:36 pm
by ja've
Running on Arch Linux, I noticed that the linux64-wx-sdl2 program hogs the CPU a lot ... Like 100% .. all the time.

I know emulation of all the hardware is cpu-intensive, but not to this extent.

With OProfile I noticed that one thread of sound.c was the guilty one. And after some investigation, I noticed that 'sound_cd_event' is set in the poll routine, checked in the sound_cd_thread() but nobody reset the poor little thing.

After applying the patch, I see no more CPU hogging and when pcem is idle, cpufreq barely needs to go above 1GHz on my i7-4770k.

Can someone tell me if this also helps on Windows?

PATCH:

Code: Select all

diff -r 36890fccc1ce src/sound.c
--- a/src/sound.c       Sun Feb 04 20:35:34 2018 +0000
+++ b/src/sound.c       Thu Feb 08 19:33:55 2018 +0100
@@ -150,6 +150,7 @@
                 int c;
                 
                 thread_wait_event(sound_cd_event, -1);
+               thread_reset_event(sound_cd_event);
                 memset(cd_buffer, 0, CD_BUFLEN*2 * 2);
                 ioctl_audio_callback(cd_buffer, CD_BUFLEN*2);
                 image_audio_callback(cd_buffer, CD_BUFLEN*2);

Re: [path] performance bugfix

Posted: Thu 08 Feb, 2018 9:17 pm
by szadycbr
woow, thanks so much for this!!!!!
edit: can you tell me how to apply this patch in linux?

Re: [path] performance bugfix

Posted: Fri 09 Feb, 2018 4:24 pm
by ja've
To apply the patch, I normally copy/paste the diff-code in a file and then do something like:

Code: Select all

# cd ~/code/pcem
# hg patch ../patches/pcem_perffix.patch

But I put the patch file as attachment to make things easier and more in line with other people posting patches here.
(it's a cleaner version with 8 space and no tabs :) )

Re: [path] performance bugfix

Posted: Sat 10 Feb, 2018 12:46 pm
by SarahWalker
Committed at rev 1021. Thanks for spotting this!