From 6d18141d880d55958c3392f6a7ae621dc33ee5c1 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 1 Dec 2011 10:53:28 +0000 Subject: 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. --- rts/Timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rts/Timer.c') diff --git a/rts/Timer.c b/rts/Timer.c index 02d106fde9..3f9bc8ab0c 100644 --- a/rts/Timer.c +++ b/rts/Timer.c @@ -48,7 +48,7 @@ handle_tick(int unused STG_UNUSED) ticks_to_ctxt_switch--; if (ticks_to_ctxt_switch <= 0) { ticks_to_ctxt_switch = RtsFlags.ConcFlags.ctxtSwitchTicks; - setContextSwitches(); /* schedule a context switch */ + contextSwitchAllCapabilities(); /* schedule a context switch */ } } -- cgit v1.2.1