[GHC] #11222: Teach strictness analysis about `catch`-like operations

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: feature | Status: new request | Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Keywords: | 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: -------------------------------------+------------------------------------- Consider the `catch#` primop, {{{#!hs catch# :: (State# RealWorld -> (# State# RealWorld, a #) ) -- ^ thing to catch exceptions from -> (b -> State# RealWorld -> (# State# RealWorld, a #) ) -- ^ exception handler -> State# RealWorld -> (# State# RealWorld, a #) }}} Semantically, this operation will always evaluate its first argument. Ideally we would indicate this in the primop's strictness signature in `primops.txt.pp`. Sadly, we can't do this at the moment due to a subtle wrinkle (discovered in #10712): Consider, {{{#!hs let r = \st -> raiseIO# blah st in catch (\st -> ...(r st)..) handler st }}} If we give the first argument of catch a strict signature, we'll get a demand `C(S)` for `r`; that is, `r` is definitely called with one argument, which indeed it is. The trouble comes when we feed `C(S)` into `r`'s RHS as the demand of the body as this will lead us to conclude that the whole `let` will diverge; clearly this isn't right. As Simon noted in ticket:10712#comment:4,
There's something very special about catch: it turns divergence into non-divergence.
In order to apply a proper strictness signature to `catch`-like operations we would need to teach the strictness analyzer about this property. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
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: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: 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 simonmar): * cc: simonmar (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
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: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: 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): * status: new => closed * resolution: => fixed Comment: Done! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: Exceptions 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: => Exceptions -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Exceptions 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 dfeuer): * status: closed => new * resolution: fixed => Comment: This was semantically shady and has been partially reverted. We would like to find a way to recover some of the benefits without the downsides. One strong possibility is to add a `catchIO#` primop that only catches exceptions thrown by `raiseIO#`. Such a primop could be handled more aggressively. See https://ghc.haskell.org/trac/ghc/wiki/Exceptions/PreciseExceptions. Another direction would be to treat `catch#` forms specially in strictness analysis, somewhat like `case` expressions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Exceptions 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 dfeuer): * owner: (none) => dfeuer -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Exceptions 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 dfeuer): * milestone: 8.2.1 => 8.4.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: dfeuer
Type: feature request | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 7.10.3
Resolution: | Keywords: Exceptions
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: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Exceptions Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10712, #14998 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sgraf): * related: => #10712, #14998 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: dfeuer Type: feature request | Status: new Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Exceptions Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10712, #14998 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by sgraf): #14998 suggests that we have the performance gains without actually making `catch#` and `catchRetry#` any more special than necessary. I think we can close this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11222: Teach strictness analysis about `catch`-like operations -------------------------------------+------------------------------------- Reporter: bgamari | Owner: dfeuer Type: feature request | Status: closed Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 7.10.3 Resolution: wontfix | Keywords: Exceptions Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10712, #14998 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => wontfix Comment:
I think we can close this?
Yes I think so. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11222#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC