[path] performance bugfix

Post Reply
User avatar
ja've
Posts: 2
Joined: Wed 07 Feb, 2018 6:46 pm
Location: europe

[path] performance bugfix

Post 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);
PC/XT Clone 8088 @ 4.77 MHz - 512kB RAM - 5.25" 180kB - MFM HDD 10MB - Hercules Gfx - White fosfor 14" crt
szadycbr
Posts: 295
Joined: Mon 21 Nov, 2016 6:23 pm

Re: [path] performance bugfix

Post by szadycbr »

woow, thanks so much for this!!!!!
edit: can you tell me how to apply this patch in linux?
User avatar
ja've
Posts: 2
Joined: Wed 07 Feb, 2018 6:46 pm
Location: europe

Re: [path] performance bugfix

Post 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 :) )
Attachments
pcem_perffix.patch
PCem sound thread performance bugfix
(435 Bytes) Downloaded 356 times
PC/XT Clone 8088 @ 4.77 MHz - 512kB RAM - 5.25" 180kB - MFM HDD 10MB - Hercules Gfx - White fosfor 14" crt
User avatar
SarahWalker
Site Admin
Posts: 2053
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [path] performance bugfix

Post by SarahWalker »

Committed at rev 1021. Thanks for spotting this!
Post Reply