[commit: ghc] master: fix occasional failure of numsparks001 test. During shutdown we (f6f0430)
Simon Marlow
marlowsd at gmail.com
Sun Aug 14 13:17:39 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/f6f04307747ca890fc06617bc63feaebd4e9aceb
>---------------------------------------------------------------
commit f6f04307747ca890fc06617bc63feaebd4e9aceb
Author: Simon Marlow <marlowsd at gmail.com>
Date: Sat Aug 13 09:40:51 2011 +0100
fix occasional failure of numsparks001 test. During shutdown we
discard all the sparks from each Capability, but we were forgetting to
account for the discarded sparks in the stats, leading to a failure of
the assertion that tests the spark invariant.
I've moved the discarding of sparks to just before the GC, to avoid
race conditions, and counted the discarded sparks as GC'd.
>---------------------------------------------------------------
rts/Schedule.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 834e3eb..4f18209 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -267,10 +267,7 @@ schedule (Capability *initialCapability, Task *task)
break;
case SCHED_INTERRUPTING:
debugTrace(DEBUG_sched, "SCHED_INTERRUPTING");
-#if defined(THREADED_RTS)
- discardSparksCap(cap);
-#endif
- /* scheduleDoGC() deletes all the threads */
+ /* scheduleDoGC() deletes all the threads */
cap = scheduleDoGC(cap,task,rtsFalse);
// after scheduleDoGC(), we must be shutting down. Either some
@@ -1433,7 +1430,19 @@ delete_threads_and_gc:
*/
if (sched_state == SCHED_INTERRUPTING) {
deleteAllThreads(cap);
- sched_state = SCHED_SHUTTING_DOWN;
+#if defined(THREADED_RTS)
+ // Discard all the sparks from every Capability. Why?
+ // They'll probably be GC'd anyway since we've killed all the
+ // threads. It just avoids the GC having to do any work to
+ // figure out that any remaining sparks are garbage.
+ for (i = 0; i < n_capabilities; i++) {
+ capabilities[i].spark_stats.gcd +=
+ sparkPoolSize(capabilities[i].sparks);
+ // No race here since all Caps are stopped.
+ discardSparksCap(&capabilities[i]);
+ }
+#endif
+ sched_state = SCHED_SHUTTING_DOWN;
}
heap_census = scheduleNeedHeapProfile(rtsTrue);
More information about the Cvs-ghc
mailing list