[GHC] #13360: Add a flag to enable inferring HasCallStack constraints

GHC ghc-devs at haskell.org
Fri Nov 10 12:03:08 UTC 2017


#13360: Add a flag to enable inferring HasCallStack constraints
-------------------------------------+-------------------------------------
        Reporter:  gridaphobe        |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by saurabhnanda):

 **UPDATE** It seems that GHC is optimising away all callstack related code
 if `callStack` is not actually being used (which was the case with
 `postgresql-simple`). Here are the same benchmarks as
 [https://ghc.haskell.org/trac/ghc/ticket/13360#comment:20: earlier], but
 with  `callStack` [https://github.com/vacationlabs/postgresql-
 simple/commit/355f0bcefacfaa6dfb808b5bbbb4fa89956650ae: actually being
 used.] There seems to be a **1.6x perf penalty** in real-world IO-centric
 code.

 It seems to be quite a big perf penalty. How do I dig deeper?

 **HasCallStack, where the callStack is actually being used**

 {{{
 benchmarking complicatedQuery/without error
 time                 289.7 μs   (250.6 μs .. 330.3 μs)
                      0.905 R²   (0.850 R² .. 0.961 R²)
 mean                 276.8 μs   (263.2 μs .. 293.6 μs)
 std dev              49.36 μs   (34.39 μs .. 70.50 μs)
 variance introduced by outliers: 92% (severely inflated)

 benchmarking complicatedQuery/with error
 time                 269.1 μs   (242.8 μs .. 294.2 μs)
                      0.947 R²   (0.919 R² .. 0.979 R²)
 mean                 274.3 μs   (262.3 μs .. 286.1 μs)
 std dev              43.09 μs   (33.99 μs .. 54.33 μs)
 variance introduced by outliers: 90% (severely inflated)
 }}}

 **Without HasCallStack**

 {{{
 benchmarking complicatedQuery/without error
 time                 183.9 μs   (179.6 μs .. 189.9 μs)
                      0.992 R²   (0.987 R² .. 0.997 R²)
 mean                 186.6 μs   (183.1 μs .. 193.1 μs)
 std dev              15.60 μs   (11.45 μs .. 20.83 μs)
 variance introduced by outliers: 74% (severely inflated)

 benchmarking complicatedQuery/with error
 time                 180.7 μs   (176.3 μs .. 187.1 μs)
                      0.992 R²   (0.984 R² .. 0.999 R²)
 mean                 181.9 μs   (179.4 μs .. 186.7 μs)
 std dev              11.55 μs   (7.139 μs .. 19.47 μs)
 variance introduced by outliers: 61% (severely inflated)
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13360#comment:22>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list