[GHC] #7923: Optimization for takeMVar/putMVar when MVar left empty
#7923: Optimization for takeMVar/putMVar when MVar left empty ------------------------------------+--------------------------------------- Reporter: ezyang | Owner: ezyang Type: task | Status: new Priority: normal | Component: Runtime System Version: 7.7 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Blockedby: Blocking: | Related: ------------------------------------+--------------------------------------- Right now, we always add an MVar to the mutable list when we takeMVar/putMVar. However, this is unnecessary when the MVar is left empty. This patch arranges that we don't add the MVar to the mutable list in those cases. I've validated the patch but haven't checked performance changes yet. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7923> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#7923: Optimization for takeMVar/putMVar when MVar left empty ---------------------------------+------------------------------------------ Reporter: ezyang | Owner: ezyang Type: task | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Runtime performance bug Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by igloo): * status: new => patch * difficulty: => Unknown -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7923#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#7923: Optimization for takeMVar/putMVar when MVar left empty ---------------------------------+------------------------------------------ Reporter: ezyang | Owner: ezyang Type: task | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Runtime performance bug Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by igloo): Shouldn't this hunk: {{{ - unlockClosure(mvar, stg_MVAR_DIRTY_info); + unlockClosure(mvar, info); + // escape without dirty_MVar! }}} use `stg_MVAR_CLEAN_info` instead of `info`? And likewise in `stg_tryTakeMVarzh`. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7923#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#7923: Optimization for takeMVar/putMVar when MVar left empty ---------------------------------+------------------------------------------ Reporter: ezyang | Owner: ezyang Type: task | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Runtime performance bug Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by igloo): ezyang pointed out that it'll be on a mutable list, so it's not as simple as just marking it clean here. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7923#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#7923: Optimization for takeMVar/putMVar when MVar left empty ---------------------------------+------------------------------------------ Reporter: ezyang | Owner: ezyang Type: task | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Runtime performance bug Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by ian@…): commit 5d9e686c30a00be08a04d9fd1c860994153a1f7a {{{ Author: Ian Lynagh <ian@well-typed.com> Date: Sat Jun 15 13:19:21 2013 +0100 Optimization for takeMVar/putMVar when MVar left empty; fixes #7923 We only need to apply the write barrier to an MVar when it acquires a reference to live data; when the MVar is left empty in the case of a takeMVar/putMVar, we can save a memory reference. Patch from Edward Z. Yang. rts/PrimOps.cmm | 49 +++++++++++++++++++++++++++++-------------------- 1 files changed, 29 insertions(+), 20 deletions(-) }}} -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7923#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#7923: Optimization for takeMVar/putMVar when MVar left empty --------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: task | Status: closed Priority: normal | Milestone: Component: Runtime System | Version: 7.7 Resolution: fixed | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: --------------------------------------+------------------------------------- Changes (by igloo): * status: patch => closed * resolution: => fixed Comment: Applied, thanks! -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7923#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (2)
-
GHC -
GHC