Improve performance of Data.List.sort(By)
This patch improves the algorithm to sort lists in base. It does so using two strategies: 1) Use a four-way-merge instead of the 'default' two-way-merge. This is able to save comparisons and allocations. 2) Use `(>) a b` over `compare a b == GT` and allow inlining and specialization. This mainly benefits types with a fast (>). Note that this *may* break instances with a *malformed* Ord instance where `a > b` is *not* equal to `compare a b == GT`. CLC proposal: https://github.com/haskell/core-libraries-committee/issues/236 Fixes #24280 ------------------------- Metric Decrease: MultiLayerModulesTH_Make T10421 T13719 T15164 T18698a T18698b T1969 T9872a T9961 T18730 WWRec T12425 T15703 -------------------------
Showing
- libraries/base/changelog.md 1 addition, 0 deletionslibraries/base/changelog.md
- libraries/ghc-internal/src/GHC/Internal/Data/OldList.hs 81 additions, 20 deletionslibraries/ghc-internal/src/GHC/Internal/Data/OldList.hs
- testsuite/tests/lib/base/Sort.hs 18 additions, 0 deletionstestsuite/tests/lib/base/Sort.hs
- testsuite/tests/lib/base/Sort.stdout 5 additions, 0 deletionstestsuite/tests/lib/base/Sort.stdout
- testsuite/tests/lib/base/all.T 1 addition, 0 deletionstestsuite/tests/lib/base/all.T
Loading
Please register or sign in to comment