5Benchmarks show that GHC 8.8 has significantly better performance than GHC 8.6
8Use the following GHC options:
14 -fspec-constr-recursive=16
17Important Note: In certain cases it is possible that GHC takes too long to
18compile with `-fspec-constr-recursive=16`, if that happens please reduce the
19value or remove that option.
21See [Explanation](#explanation) for details about these flags.
25In many cases `fusion-plugin` can improve performance by better stream
26fusion. However, in some cases performance may also regress. Please note
27that the `fusion-plugin` package works only for GHC >= 8.6.
30[fusion-plugin](https://hackage.haskell.org/package/fusion-plugin)
31package or add it to the `build-depends` section of your program in the
34* Use the following GHC option in addition to the options listed in the
38 -fplugin=Fusion.Plugin
43At the very least `-O -fdicts-strict` compilation options are
44required. If these options are not used, the program may exhibit memory
45hog. For example, the following program, if compiled without an
46optimization option, is known to hog memory:
49main = S.drain $ S.concatMap S.fromList $ S.repeat []
54* `-fdicts-strict` is needed to avoid [a GHC
55issue](https://gitlab.haskell.org/ghc/ghc/issues/17745) leading to
56memory leak in some cases.
58* `-fspec-constr-recursive` is needed for better stream fusion by enabling
59the `SpecConstr` optimization in more cases. Large values used with this flag
60may lead to huge compilation times and code bloat, if that happens please avoid
61it or use a lower value (e.g. 3 or 4).
63* `-fmax-worker-args` is needed for better stream fusion by enabling the
64`SpecConstr` optimization in some important cases.
66* `-fplugin=Fusion.Plugin` enables predictable stream fusion
67optimization in certain cases by helping the compiler inline internal
68bindings and therefore enabling case-of-case optimization. In some
69cases, especially in some file IO benchmarks, it can make a difference of
705-10x better performance.
72# Multi-core Parallelism
74Concurrency without a threaded runtime may be a bit more efficient. Do not use
75threaded runtime unless you really need multi-core parallelism. To get
76multi-core parallelism use the following GHC options:
78 `-threaded -with-rtsopts "-N"`
82Use GHC 8.8 for best performance.
84GHC 8.2.2 may hog memory and hang when building certain application using
85streamly (particularly the benchmark programs in the streamly package).
86Therefore we recommend avoiding using the GHC version 8.2.x.
88# Performance Optimizations
90If performance is below expectations:
92* Look for inlining functions in the fast path
93* Strictness annotations on data, specially the data used as accumulator in
94 folds and scans, can help in improving performance.
95* Strictness annotations on function arguments can help the compiler unbox
96 constructors in certain cases, improving performance.
97* Sometimes using `-XStrict` extension can help improve performance, if so you
98 may be missing some strictness annotations.
99* Use tail recursion for streaming data or for large loops
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list