From ba733a0f6b6b5d977e3f41d373a56f570691b1eb Mon Sep 17 00:00:00 2001 From: "simonmar@microsoft.com" Date: Thu, 29 Nov 2007 15:49:27 +0000 Subject: [PATCH] GC: small improvement to parallelism don't cache a work block locally if the global queue is empty --- rts/sm/GCUtils.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/rts/sm/GCUtils.c b/rts/sm/GCUtils.c index 6341067..a8f0099 100644 --- a/rts/sm/GCUtils.c +++ b/rts/sm/GCUtils.c @@ -109,11 +109,21 @@ gc_alloc_todo_block (step_workspace *ws) // push out the block out if it is already the scan block. if (ws->todo_bd != NULL && ws->scan_bd != ws->todo_bd) { ASSERT(ws->todo_bd->link == NULL); - if (ws->buffer_todo_bd != NULL) { + if (ws->buffer_todo_bd == NULL) { + // If the global todo list is empty, push this block + // out immediately rather than caching it in + // buffer_todo_bd, because there might be other threads + // waiting for work. + if (ws->stp->todos == NULL) { + push_todo_block(ws->todo_bd, ws->stp); + } else { + ws->buffer_todo_bd = ws->todo_bd; + } + } else { ASSERT(ws->buffer_todo_bd->link == NULL); push_todo_block(ws->buffer_todo_bd, ws->stp); - } - ws->buffer_todo_bd = ws->todo_bd; + ws->buffer_todo_bd = ws->todo_bd; + } ws->todo_bd = NULL; } -- 1.7.10.4