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

GHC ghc-devs at haskell.org
Fri Nov 10 07:48:15 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):

 Does this seem like a sensible benchmark for a pure function that throws
 an Exception: https://github.com/vacationlabs/hascallstack-
 benchmarks/blob/f055b16db7bf42e069daf25e126bd04a3c8b65bc/app/Main.hs

 Here are the numbers, which seem to be suggesting a 6-7x perf penalty for
 using `HasCallstack`, which seems to be getting worse as the depth of the
 callstack increases:

 * factorial/20: 4x penalty
 * factorial/30: 4.8x penalty
 * factorial/50: 5.9x penalty
 * factorial/100: 6.9x penalty
 * factorial/200: 7.7x penalty
 * factorial/300: 7.8x penalty

 Can someone confirm this pattern on their machine as well?

 {{{
 benchmarking factorial/regular/20
 time                 1.757 μs   (1.734 μs .. 1.782 μs)
                      0.999 R²   (0.998 R² .. 1.000 R²)
 mean                 1.732 μs   (1.722 μs .. 1.753 μs)
 std dev              41.67 ns   (26.25 ns .. 72.27 ns)
 variance introduced by outliers: 30% (moderately inflated)

 benchmarking factorial/callstack/20
 time                 7.080 μs   (7.041 μs .. 7.138 μs)
                      1.000 R²   (0.999 R² .. 1.000 R²)
 mean                 7.087 μs   (7.058 μs .. 7.135 μs)
 std dev              128.1 ns   (88.70 ns .. 183.6 ns)
 variance introduced by outliers: 17% (moderately inflated)

 benchmarking factorial/regular/30
 time                 2.142 μs   (2.129 μs .. 2.161 μs)
                      0.999 R²   (0.998 R² .. 1.000 R²)
 mean                 2.155 μs   (2.140 μs .. 2.192 μs)
 std dev              76.73 ns   (47.29 ns .. 132.5 ns)
 variance introduced by outliers: 48% (moderately inflated)

 benchmarking factorial/callstack/30
 time                 10.42 μs   (10.34 μs .. 10.53 μs)
                      0.999 R²   (0.998 R² .. 1.000 R²)
 mean                 10.65 μs   (10.53 μs .. 10.84 μs)
 std dev              527.4 ns   (362.1 ns .. 827.1 ns)
 variance introduced by outliers: 60% (severely inflated)

 benchmarking factorial/regular/50
 time                 2.962 μs   (2.933 μs .. 3.007 μs)
                      0.998 R²   (0.997 R² .. 1.000 R²)
 mean                 2.972 μs   (2.947 μs .. 3.021 μs)
 std dev              119.0 ns   (80.88 ns .. 181.1 ns)
 variance introduced by outliers: 53% (severely inflated)

 benchmarking factorial/callstack/50
 time                 17.56 μs   (17.26 μs .. 18.13 μs)
                      0.993 R²   (0.979 R² .. 0.999 R²)
 mean                 17.62 μs   (17.34 μs .. 18.34 μs)
 std dev              1.365 μs   (588.7 ns .. 2.620 μs)
 variance introduced by outliers: 77% (severely inflated)

 benchmarking factorial/regular/100
 time                 4.920 μs   (4.883 μs .. 4.973 μs)
                      0.999 R²   (0.998 R² .. 1.000 R²)
 mean                 4.969 μs   (4.915 μs .. 5.037 μs)
 std dev              200.2 ns   (144.0 ns .. 264.3 ns)
 variance introduced by outliers: 52% (severely inflated)

 benchmarking factorial/callstack/100
 time                 33.78 μs   (33.63 μs .. 33.99 μs)
                      0.999 R²   (0.999 R² .. 1.000 R²)
 mean                 34.36 μs   (34.04 μs .. 34.98 μs)
 std dev              1.493 μs   (1.015 μs .. 2.390 μs)
 variance introduced by outliers: 50% (moderately inflated)

 benchmarking factorial/regular/200
 time                 9.002 μs   (8.921 μs .. 9.131 μs)
                      0.999 R²   (0.998 R² .. 1.000 R²)
 mean                 9.132 μs   (9.052 μs .. 9.229 μs)
 std dev              299.3 ns   (238.2 ns .. 375.3 ns)
 variance introduced by outliers: 39% (moderately inflated)

 benchmarking factorial/callstack/200
 time                 69.26 μs   (67.10 μs .. 71.77 μs)
                      0.995 R²   (0.992 R² .. 1.000 R²)
 mean                 68.59 μs   (67.86 μs .. 69.60 μs)
 std dev              2.830 μs   (1.919 μs .. 3.858 μs)
 variance introduced by outliers: 44% (moderately inflated)

 benchmarking factorial/regular/300
 time                 12.93 μs   (12.90 μs .. 12.97 μs)
                      0.999 R²   (0.999 R² .. 1.000 R²)
 mean                 13.27 μs   (13.11 μs .. 13.51 μs)
 std dev              597.3 ns   (422.6 ns .. 842.9 ns)
 variance introduced by outliers: 54% (severely inflated)

 benchmarking factorial/callstack/300
 time                 101.2 μs   (100.7 μs .. 101.7 μs)
                      0.999 R²   (0.999 R² .. 1.000 R²)
 mean                 103.9 μs   (102.5 μs .. 105.9 μs)
 std dev              5.361 μs   (3.981 μs .. 6.618 μs)
 variance introduced by outliers: 54% (severely inflated)
 }}}

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


More information about the ghc-tickets mailing list