Fix a scheduling bug in the threaded RTS
authorSimon Marlow <marlowsd@gmail.com>
Thu, 1 Dec 2011 10:53:28 +0000 (10:53 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 1 Dec 2011 11:29:53 +0000 (11:29 +0000)
commit6d18141d880d55958c3392f6a7ae621dc33ee5c1
treeedd5607a50a92ffad4707cef792a06246b5b41e4
parent1d012e31577951ff5fe74d0277fabdb08c27929d
Fix a scheduling bug in the threaded RTS

The parallel GC was using setContextSwitches() to stop all the other
threads, which sets the context_switch flag on every Capability.  That
had the side effect of causing every Capability to also switch
threads, and since GCs can be much more frequent than context
switches, this increased the context switch frequency.  When context
switches are expensive (because the switch is between two bound
threads or a bound and unbound thread), the difference is quite
noticeable.

The fix is to have a separate flag to indicate that a Capability
should stop and return to the scheduler, but not switch threads.  I've
called this the "interrupt" flag.
includes/mkDerivedConstants.c
rts/Capability.c
rts/Capability.h
rts/HeapStackCheck.cmm
rts/Messages.c
rts/Schedule.c
rts/Timer.c
rts/sm/GC.c