Please sign in to comment.
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.
- Loading branch information...
Showing with 362 additions and 437 deletions.
- +4 −0 includes/mkDerivedConstants.c
- +6 −2 includes/rts/Constants.h
- +2 −1 includes/rts/storage/Block.h
- +10 −4 includes/rts/storage/Closures.h
- +0 −1 includes/rts/storage/TSO.h
- +4 −5 includes/stg/MiscClosures.h
- +4 −4 rts/Capability.h
- +5 −5 rts/HeapStackCheck.cmm
- +1 −0 rts/Inlines.c
- +2 −17 rts/Messages.c
- +195 −155 rts/PrimOps.cmm
- +63 −78 rts/RaiseAsync.c
- +6 −33 rts/Schedule.c
- +7 −2 rts/StgMiscClosures.cmm
- +49 −124 rts/Threads.c
- +1 −2 rts/Threads.h
- +2 −2 rts/sm/Compact.c
- +1 −2 rts/sm/Scav.c
Oops, something went wrong.