
#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): **I think we are aren't approaching this pragmatically.** The 3.4x penalty, reported above, occurs only when every single computation throws an error and the error/callstack is forced (usually by printing it to a log-file). **However** in real life only a certain percentage of computations fail, and most of the times the callstacks aren't evaluated completely. (I tried a version where `e deepseq` wasn't being called and every version of the code had the same perf. Here are some benchmarks where **only 20% computations fail**. [https://github.com/vacationlabs/hascallstack- benchmarks/blob/84ab56c63eb96208c5193a187b431251037a2ce8/app/Main.hs: code is here] The perf penalty is now **~1.2x** for the `HasCallStack` version. I think there is still some opportunity to optimise the stack entries, but the perf penalty in real-world scenarios is not as alarming as I had earlier reported. **This is going to be 'Exhibit A' whenever I need to cite advantages of lazy evaluation** {{{ benchmarking recur/no callstack/1000 time 1.720 ms (1.648 ms .. 1.776 ms) 0.992 R² (0.987 R² .. 0.996 R²) mean 1.668 ms (1.638 ms .. 1.703 ms) std dev 117.6 μs (97.03 μs .. 144.4 μs) variance introduced by outliers: 53% (severely inflated) benchmarking recur/HasCallStack/1000 time 1.700 ms (1.660 ms .. 1.742 ms) 0.994 R² (0.990 R² .. 0.997 R²) mean 1.725 ms (1.695 ms .. 1.762 ms) std dev 117.1 μs (95.96 μs .. 150.7 μs) variance introduced by outliers: 52% (severely inflated) benchmarking recur/explicit callstack/1000 time 1.740 ms (1.701 ms .. 1.782 ms) 0.994 R² (0.991 R² .. 0.997 R²) mean 1.746 ms (1.710 ms .. 1.779 ms) std dev 126.3 μs (101.9 μs .. 158.5 μs) variance introduced by outliers: 53% (severely inflated) benchmarking recur/explicit callstack (mini)/1000 time 1.694 ms (1.639 ms .. 1.758 ms) 0.988 R² (0.976 R² .. 0.995 R²) mean 1.735 ms (1.701 ms .. 1.783 ms) std dev 135.1 μs (102.7 μs .. 180.1 μs) variance introduced by outliers: 58% (severely inflated) benchmarking recur/no callstack/10000 time 16.70 ms (14.62 ms .. 18.45 ms) 0.941 R² (0.888 R² .. 0.975 R²) mean 19.34 ms (18.32 ms .. 20.57 ms) std dev 2.575 ms (1.965 ms .. 3.431 ms) variance introduced by outliers: 62% (severely inflated) benchmarking recur/HasCallStack/10000 time 20.03 ms (18.44 ms .. 21.43 ms) 0.955 R² (0.911 R² .. 0.979 R²) mean 19.07 ms (17.62 ms .. 20.33 ms) std dev 3.299 ms (2.438 ms .. 4.141 ms) variance introduced by outliers: 71% (severely inflated) benchmarking recur/explicit callstack/10000 time 21.81 ms (20.15 ms .. 22.95 ms) 0.967 R² (0.919 R² .. 0.993 R²) mean 21.22 ms (19.91 ms .. 22.07 ms) std dev 2.337 ms (1.799 ms .. 3.171 ms) variance introduced by outliers: 51% (severely inflated) benchmarking recur/explicit callstack (mini)/10000 time 18.23 ms (15.22 ms .. 20.59 ms) 0.904 R² (0.825 R² .. 0.960 R²) mean 20.31 ms (18.68 ms .. 21.64 ms) std dev 3.227 ms (2.640 ms .. 3.903 ms) variance introduced by outliers: 71% (severely inflated) benchmarking recur/no callstack/100000 time 199.8 ms (119.6 ms .. 283.6 ms) 0.857 R² (0.493 R² .. 1.000 R²) mean 199.5 ms (152.1 ms .. 232.5 ms) std dev 49.70 ms (37.44 ms .. 59.33 ms) variance introduced by outliers: 65% (severely inflated) benchmarking recur/HasCallStack/100000 time 210.9 ms (166.5 ms .. 262.5 ms) 0.970 R² (0.924 R² .. 1.000 R²) mean 170.5 ms (152.4 ms .. 188.6 ms) std dev 21.57 ms (13.10 ms .. 33.13 ms) variance introduced by outliers: 32% (moderately inflated) benchmarking recur/explicit callstack/100000 time 288.3 ms (229.0 ms .. 398.6 ms) 0.965 R² (0.893 R² .. 1.000 R²) mean 242.8 ms (192.7 ms .. 270.7 ms) std dev 48.74 ms (11.69 ms .. 64.53 ms) variance introduced by outliers: 57% (severely inflated) benchmarking recur/explicit callstack (mini)/100000 time 215.5 ms (73.60 ms .. 322.8 ms) 0.804 R² (0.327 R² .. 1.000 R²) mean 212.8 ms (157.4 ms .. 242.9 ms) std dev 50.88 ms (24.98 ms .. 66.53 ms) variance introduced by outliers: 65% (severely inflated) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13360#comment:26 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler