diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2018-09-11 20:43:50 +0200 |
---|---|---|
committer | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2018-09-11 20:43:51 +0200 |
commit | 36740b4c346c619e31d24d6672caa6f4f7fea123 (patch) | |
tree | 58d200db894d385378b53b1d3298b4d808d6207c | |
parent | d36b1ffac9960db70043aaab43c931ce217912ba (diff) | |
download | haskell-36740b4c346c619e31d24d6672caa6f4f7fea123.tar.gz |
Revert incorrect STM wakeup optimisation
Summary: (see the comments)
Reviewers: simonmar, bgamari, erikd
Reviewed By: simonmar
Subscribers: rwbarton, carter
Differential Revision: https://phabricator.haskell.org/D5144
-rw-r--r-- | rts/STM.c | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -337,11 +337,11 @@ static void unpark_tso(Capability *cap, StgTSO *tso) { // it belongs to this cap, or send a message to the owning cap // otherwise. - // But we don't really want to send multiple messages if we write - // to the same TVar multiple times, and the owning cap hasn't yet - // woken up the thread and removed it from the TVar's watch list. - // So, we use the tso->block_info as a flag to indicate whether - // we've already done tryWakeupThread() for this thread. + // TODO: This sends multiple messages if we write to the same TVar multiple + // times and the owning cap hasn't yet woken up the thread and removed it + // from the TVar's watch list. We tried to optimise this in D4961, but that + // patch was incorrect and broke other things, see #15544 comment:17. See + // #15626 for the tracking ticket. // Safety Note: we hold the TVar lock at this point, so we know // that this thread is definitely still blocked, since the first @@ -349,12 +349,7 @@ static void unpark_tso(Capability *cap, StgTSO *tso) { // TVar watch queues, and to do that it would need to lock the // TVar. - if (tso->block_info.closure != &stg_STM_AWOKEN_closure) { - // safe to do a non-atomic test-and-set here, because it's - // fine if we do multiple tryWakeupThread()s. - tso->block_info.closure = &stg_STM_AWOKEN_closure; - tryWakeupThread(cap,tso); - } + tryWakeupThread(cap,tso); } static void unpark_waiters_on(Capability *cap, StgTVar *s) { |