Closed GoogleCodeExporter closed 8 years ago
In case anyone wonders: There are some online blogs and benchmarks that
discourage
the use of Sleep(0). It's bogus information.
On Win95/98 systems Sleep(0) was indeed bad news. It would behave erratically
(although with timeBeginPeriod(1) was usually ok). Still, Sleep(1) yielded more
consistent results and so it was preferred. Win95 is dead. We don't care.
Windows XP introduces a new quirk. XP has an auto-adjusting priority
scheduler, and
it *will* throttle threads into lower priority ratings if those threads are
spending
a lot of time sleeping. XP counts Sleep(1) as "more idle" than Sleep(0), and
thus
much more likely to be throttled. This is why my "only run when the system is
idle"
processes would start running while I was playing a non-intensive game under
PCSX2
(ie, one that runs full framerate with plenty of cycles to spare). This is
also when
laptops throttle their CPU into low-speed mode.
Thus Sleep(0) is good, especially with the timeBeginPeriod set.
Concerning laptops: Every laptop I've used (which are only three, admittedly)
had
kernel timeslice resolutions in excess of 20ms. Even a basic idle wait loop
couldn't
maintain a consistent 60fps rate, and it usually liked to wreak havoc on the
audio
too (+/-20ms is an eternity in directsound latency terms). I'm pretty sure most
modern laptops still follow the same practice, because it's really good at
conserving
battery life while still maintaining high performance on dedicated single-thread
activities. And when you kick up to play a DVD movie or what not, the player
and/or
drivers just up the timeslice resolution while they're running. Now PCSX2 can
do the
same. :)
... just make sure the heating vents on your laptop are unobstructed before
settling
in for a long emulation session. heh.
Original comment by Jake.Stine
on 25 Oct 2008 at 9:49
I'll run a few tests with this when I'm back at my beefy home pc :p
I can imagine this is the cause for the sporadically different benchmarks
results I
always have.
Original comment by ramapcsx2
on 25 Oct 2008 at 10:13
Ok, this is helping SPU2Ghz, it's helping the sync when speedhacks are enabled
(Persona3 videos work better).
And it'll help when other processes want to "steal" cpu for themselves.
This is a keeper :p
Original comment by ramapcsx2
on 25 Oct 2008 at 1:29
Original issue reported on code.google.com by
Jake.Stine
on 24 Oct 2008 at 11:32Attachments: