Re: [GHC] #693: dynamic locking

#693: dynamic locking ----------------------------+---------------------------------------------- Reporter: | Owner: simonmar simonmar | Status: closed Type: task | Milestone: 7.8.1 Priority: low | Version: 6.4.1 Component: Runtime | Keywords: System | Architecture: Unknown/Multiple Resolution: fixed | Difficulty: Moderate (less than a day) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: N/A | Blocking: | ----------------------------+---------------------------------------------- Comment (by parcs): I think `atomicModifyMutVar#` and `noDuplicate#` could be optimized in a similar fashion. When `n_capabilities == 1`, `atomicModifyMutVar#` could update the `MutVar` in a faster (1.8x), non-atomic fashion instead of using a compare-and-swap. Similarly, `noDuplicate#` could elide the call to `threadPaused` since there is no possibility of work being duplicated. Are these safe assumptions? How does this patch look? `./validate` seems content with it, at least. {{{ diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index ced15ee..863c352 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -340,6 +340,15 @@ stg_atomicModifyMutVarzh ( gcptr mv, gcptr f ) LDV_RECORD_CREATE(r); StgThunk_payload(r,0) = z; +#ifdef THREADED_RTS + if (CInt[n_capabilities] == 1 :: CInt) { + x = StgMutVar_var(mv); + StgThunk_payload(z,1) = x; + StgMutVar_var(mv) = y; + goto out; + } +#endif + retry: x = StgMutVar_var(mv); StgThunk_payload(z,1) = x; @@ -350,6 +359,7 @@ stg_atomicModifyMutVarzh ( gcptr mv, gcptr f ) StgMutVar_var(mv) = y; #endif +out: if (GET_INFO(mv) == stg_MUT_VAR_CLEAN_info) { ccall dirty_MUT_VAR(BaseReg "ptr", mv "ptr"); } @@ -2008,6 +2018,10 @@ INFO_TABLE_RET(stg_noDuplicate, RET_SMALL, W_ info_ptr) stg_noDuplicatezh /* no arg list: explicit stack layout */ { + if (CInt[n_capabilities] == 1 :: CInt) { + jump %ENTRY_CODE(Sp(0)) []; + } + STK_CHK(WDS(1), stg_noDuplicatezh); // leave noDuplicate frame in case the current }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/693#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC