diff options
author | Simon Marlow <marlowsd@gmail.com> | 2010-04-01 09:16:05 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2010-04-01 09:16:05 +0000 |
commit | f4692220c7cbdadaa633f50eb2b30b59edb30183 (patch) | |
tree | 3d29f1b4770bedb7c69c31b2828f9b5acca3e2c3 /rts/HeapStackCheck.cmm | |
parent | 7c4cb84efd774a21f11fb03118feb0434282ecf3 (diff) | |
download | haskell-f4692220c7cbdadaa633f50eb2b30b59edb30183.tar.gz |
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.
Diffstat (limited to 'rts/HeapStackCheck.cmm')
-rw-r--r-- | rts/HeapStackCheck.cmm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rts/HeapStackCheck.cmm b/rts/HeapStackCheck.cmm index f8bccc091d..f8195768fb 100644 --- a/rts/HeapStackCheck.cmm +++ b/rts/HeapStackCheck.cmm @@ -481,9 +481,13 @@ INFO_TABLE_RET( stg_gc_gen, RET_DYN ) stg_gc_gen { + // Hack; see Note [mvar-heap-check] in PrimOps.cmm + if (R10 == stg_putMVarzh || R10 == stg_takeMVarzh) { + unlockClosure(R1, stg_MVAR_DIRTY_info) + } SAVE_EVERYTHING; GC_GENERIC -} +} // A heap check at an unboxed tuple return point. The return address // is on the stack, and we can find it by using the offsets given @@ -583,11 +587,7 @@ INFO_TABLE_RET( stg_block_takemvar, RET_SMALL, P_ unused ) // code fragment executed just before we return to the scheduler stg_block_takemvar_finally { -#ifdef THREADED_RTS unlockClosure(R3, stg_MVAR_DIRTY_info); -#else - SET_INFO(R3, stg_MVAR_DIRTY_info); -#endif jump StgReturn; } |