diff options
author | Simon Marlow <marlowsd@gmail.com> | 2010-03-29 14:44:56 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2010-03-29 14:44:56 +0000 |
commit | 5d52d9b64c21dcf77849866584744722f8121389 (patch) | |
tree | 25aeafc9b761e73714c24ae414c0b1c41765c99f /rts/Updates.h | |
parent | 79957d77c1bff767f1041d3fabdeb94d92a52878 (diff) | |
download | haskell-5d52d9b64c21dcf77849866584744722f8121389.tar.gz |
New implementation of BLACKHOLEs
This replaces the global blackhole_queue with a clever scheme that
enables us to queue up blocked threads on the closure that they are
blocked on, while still avoiding atomic instructions in the common
case.
Advantages:
- gets rid of a locked global data structure and some tricky GC code
(replacing it with some per-thread data structures and different
tricky GC code :)
- wakeups are more prompt: parallel/concurrent performance should
benefit. I haven't seen anything dramatic in the parallel
benchmarks so far, but a couple of threading benchmarks do improve
a bit.
- waking up a thread blocked on a blackhole is now O(1) (e.g. if
it is the target of throwTo).
- less sharing and better separation of Capabilities: communication
is done with messages, the data structures are strictly owned by a
Capability and cannot be modified except by sending messages.
- this change will utlimately enable us to do more intelligent
scheduling when threads block on each other. This is what started
off the whole thing, but it isn't done yet (#3838).
I'll be documenting all this on the wiki in due course.
Diffstat (limited to 'rts/Updates.h')
-rw-r--r-- | rts/Updates.h | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/rts/Updates.h b/rts/Updates.h index 2b3c35df0c..de9276c909 100644 --- a/rts/Updates.h +++ b/rts/Updates.h @@ -48,8 +48,7 @@ BEGIN_RTS_PRIVATE W_ sz; \ W_ i; \ inf = %GET_STD_INFO(p); \ - if (%INFO_TYPE(inf) != HALF_W_(BLACKHOLE) \ - && %INFO_TYPE(inf) != HALF_W_(CAF_BLACKHOLE)) { \ + if (%INFO_TYPE(inf) != HALF_W_(BLACKHOLE)) { \ if (%INFO_TYPE(inf) == HALF_W_(THUNK_SELECTOR)) { \ sz = BYTES_TO_WDS(SIZEOF_StgSelector_NoThunkHdr); \ } else { \ @@ -82,7 +81,6 @@ FILL_SLOP(StgClosure *p) switch (inf->type) { case BLACKHOLE: - case CAF_BLACKHOLE: goto no_slop; // we already filled in the slop when we overwrote the thunk // with BLACKHOLE, and also an evacuated BLACKHOLE is only the @@ -127,23 +125,21 @@ no_slop: */ #ifdef CMINUSMINUS -#define updateWithIndirection(ind_info, p1, p2, and_then) \ +#define updateWithIndirection(p1, p2, and_then) \ W_ bd; \ \ DEBUG_FILL_SLOP(p1); \ LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC(p1); \ StgInd_indirectee(p1) = p2; \ prim %write_barrier() []; \ + SET_INFO(p1, stg_BLACKHOLE_info); \ + LDV_RECORD_CREATE(p1); \ bd = Bdescr(p1); \ if (bdescr_gen_no(bd) != 0 :: bits16) { \ recordMutableCap(p1, TO_W_(bdescr_gen_no(bd)), R1); \ - SET_INFO(p1, stg_IND_OLDGEN_info); \ - LDV_RECORD_CREATE(p1); \ TICK_UPD_OLD_IND(); \ and_then; \ } else { \ - SET_INFO(p1, ind_info); \ - LDV_RECORD_CREATE(p1); \ TICK_UPD_NEW_IND(); \ and_then; \ } @@ -151,7 +147,6 @@ no_slop: #else /* !CMINUSMINUS */ INLINE_HEADER void updateWithIndirection (Capability *cap, - const StgInfoTable *ind_info, StgClosure *p1, StgClosure *p2) { @@ -164,25 +159,19 @@ INLINE_HEADER void updateWithIndirection (Capability *cap, LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC(p1); ((StgInd *)p1)->indirectee = p2; write_barrier(); + SET_INFO(p1, &stg_BLACKHOLE_info); + LDV_RECORD_CREATE(p1); bd = Bdescr((StgPtr)p1); if (bd->gen_no != 0) { recordMutableCap(p1, cap, bd->gen_no); - SET_INFO(p1, &stg_IND_OLDGEN_info); TICK_UPD_OLD_IND(); } else { - SET_INFO(p1, ind_info); - LDV_RECORD_CREATE(p1); TICK_UPD_NEW_IND(); } } #endif /* CMINUSMINUS */ -#define UPD_IND(cap, updclosure, heapptr) \ - updateWithIndirection(cap, &stg_IND_info, \ - updclosure, \ - heapptr) - #ifndef CMINUSMINUS END_RTS_PRIVATE #endif |