
#10788: performance regression involving minimum
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: ekmett
Type: bug | Status: new
Priority: normal | Milestone:
Component: Core Libraries | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by nomeata):
With
{{{
{-# SPECIALIZE minimum :: [Int] -> Int #-}
}}}
instead of the rule rewriting it to strictMinimum, and *not* adding an
INLINE pragma to `minimum`, I get good code in `GHC.List`, and this is
being used here without too much inlining (it inlines the wrapper that
distinguishes `[]` from a non-empty list and unboxes the int, but then
calls the wrapper in `GHC.List.$wgo1`.
Removing `INLINE` is important, as otherwise we’d be having this worker in
every use of minimum.
Even without `INLINE` we have this in the interface
{{{
minimum :: Ord a => [a] -> a
{- Arity: 2, Strictness: ,
Unfolding: (\ @ a11 $dOrd :: Ord a11 ds :: [a11] ->
case ds of wild {
[] -> minimum3 @ a11
: ipv ipv1
-> let {
k :: a11 -> a11 -> a11 = min @ a11 $dOrd
} in
letrec {
go :: [a11] -> a11 -> a11 {- Arity: 2, Strictness: