From f4692220c7cbdadaa633f50eb2b30b59edb30183 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 1 Apr 2010 09:16:05 +0000 Subject: Change the representation of the MVar blocked queue The list of threads blocked on an MVar is now represented as a list of separately allocated objects rather than being linked through the TSOs themselves. This lets us remove a TSO from the list in O(1) time rather than O(n) time, by marking the list object. Removing this linear component fixes some pathalogical performance cases where many threads were blocked on an MVar and became unreachable simultaneously (nofib/smp/threads007), or when sending an asynchronous exception to a TSO in a long list of thread blocked on an MVar. MVar performance has actually improved by a few percent as a result of this change, slightly to my surprise. This is the final cleanup in the sequence, which let me remove the old way of waking up threads (unblockOne(), MSG_WAKEUP) in favour of the new way (tryWakeupThread and MSG_TRY_WAKEUP, which is idempotent). It is now the case that only the Capability that owns a TSO may modify its state (well, almost), and this simplifies various things. More of the RTS is based on message-passing between Capabilities now. --- rts/StgMiscClosures.cmm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'rts/StgMiscClosures.cmm') diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 7e1e6a73d5..1dec6e68b7 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -491,8 +491,6 @@ CLOSURE(stg_NO_TREC_closure,stg_NO_TREC); ------------------------------------------------------------------------- */ // PRIM rather than CONSTR, because PRIM objects cannot be duplicated by the GC. -INFO_TABLE_CONSTR(stg_MSG_WAKEUP,2,0,0,PRIM,"MSG_WAKEUP","MSG_WAKEUP") -{ foreign "C" barf("MSG_WAKEUP object entered!") never returns; } INFO_TABLE_CONSTR(stg_MSG_TRY_WAKEUP,2,0,0,PRIM,"MSG_TRY_WAKEUP","MSG_TRY_WAKEUP") { foreign "C" barf("MSG_TRY_WAKEUP object entered!") never returns; } @@ -572,6 +570,13 @@ INFO_TABLE( stg_dummy_ret, 0, 0, CONSTR_NOCAF_STATIC, "DUMMY_RET", "DUMMY_RET") } CLOSURE(stg_dummy_ret_closure,stg_dummy_ret); +/* ---------------------------------------------------------------------------- + MVAR_TSO_QUEUE + ------------------------------------------------------------------------- */ + +INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE") +{ foreign "C" barf("MVAR_TSO_QUEUE object entered!") never returns; } + /* ---------------------------------------------------------------------------- CHARLIKE and INTLIKE closures. -- cgit v1.2.1