[GHC] #8585: Loopification should omit stack check

#8585: Loopification should omit stack check ------------------------------+-------------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Runtime performance bug Unknown/Multiple | Test Case: Difficulty: Unknown | Blocking: Blocked By: | Related Tickets: | ------------------------------+-------------------------------------------- When we optimize a self-recursive tail call using loopification we don't need to perform a stack check in every loop. This is because a tail recursive function uses constant amount of stack. We should therefore place the loop header after the stack check, but before the heap check (because heap may grow in every call). parcs proposed a patch [https://ghc.haskell.org/trac/ghc/ticket/8275#comment:34 here]. We just need to make sure why it works and add some documentation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8585 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8585: Loopification should omit stack check --------------------------------------------+------------------------------ Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime performance bug | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Changes (by jstolarek): * cc: patrick@…, jan.stolarek@… (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8585#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8585: Loopification should omit stack check --------------------------------------------+------------------------------ Reporter: jstolarek | Owner: jstolarek Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime performance bug | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Changes (by jstolarek): * owner: => jstolarek Comment: Patrick, your patch validates successfully. I now see that it indeed places the loop header in the right place. What I don't fully understand in the code that generates the loop header: {{{ self_loop_info <- getSelfLoop case self_loop_info of Just (_, loop_header_id, _) | checkYield && isJust mb_stk_hwm -> emitLabel loop_header_id _otherwise -> return () }}} is the additional condition `checkYield && isJust mb_stk_hwm`. My understanding is that currently heap checks can be placed not only at the entry point to a function but also in the case alternatives, thunk entry points and few other places (according to Note [Heap checks]). We however want to emit loop header only before the heap check made when entering a function and I guess that `checkYield && isJust mb_stk_hwm` condition accomplishes just that. Is that correct? I wasn't able yet to fully convince myself that this always works. I'm not committing the fix until I am certain that it will always work the way we intend it to. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8585#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8585: Loopification should omit stack check
--------------------------------------------+------------------------------
Reporter: jstolarek | Owner: jstolarek
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime performance bug | Unknown/Multiple
Test Case: | Difficulty: Unknown
Blocking: | Blocked By:
| Related Tickets:
--------------------------------------------+------------------------------
Comment (by Jan Stolarek

#8585: Loopification should omit stack check --------------------------------------------+------------------------------ Reporter: jstolarek | Owner: jstolarek Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime performance bug | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Changes (by jstolarek): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8585#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8585: Loopification should omit stack check -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: jstolarek Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: fixed | Keywords: CodeGen Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: => CodeGen -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8585#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC