Skip to content

Commit ab3ab3e

Browse files
luiteMarge Bot
authored and
Marge Bot
committed
compiler/coreprep: Turn off dictionary speculation by default
Speculative evaluation can cause performance regressions, therefore we turn it off by default. It can be enabled again with the -fspec-eval-dictfun flag See #25284
1 parent 2d62b97 commit ab3ab3e

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

compiler/GHC/CoreToStg/Prep.hs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,12 +2054,27 @@ floats and how far they go.
20542054
Note [Controlling Speculative Evaluation]
20552055
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20562056
2057-
Most of the time, speculative evaluation has a positive effect on performance,
2058-
but we have found a case where speculative evaluation of dictionary functions
2059-
leads to a performance regression #25284.
2060-
2061-
Therefore we have some flags to control it. See the optimization section in
2062-
the User's Guide for the description of these flags and when to use them.
2057+
Most of the time, speculative evaluation in the coreprep phase has a positive
2058+
effect on performance, however we have found that some forms of speculative
2059+
evaluation can lead to large performance regressions. See #25284.
2060+
2061+
Therefore we have some flags to control which types of speculative evaluation
2062+
are done:
2063+
2064+
-fspec-eval
2065+
Globally enable/disable speculative evaluation ( -fno-spec-eval also turns
2066+
off all other speculative evaluation). On by default for all
2067+
optimization levels. Turning on this flag by itself should never cause
2068+
a performance regression. Please open a ticket if you find any.
2069+
2070+
-fspec-eval-dictfun
2071+
Enable speculative evaluation for dictionary functions. Off by default
2072+
since it can cause an increase in allocations (#24284). We have no
2073+
examples that show a large performance improvement when turning on this
2074+
flag. Please open a ticket if you find any.
2075+
2076+
Also see the optimization section in the User's Guide for the description of
2077+
these flags and when to use them.
20632078
20642079
Note [Floats and FloatDecision]
20652080
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compiler/GHC/Driver/DynFlags.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ optLevelFlags -- see Note [Documenting optimisation flags]
12881288
-- , ([2], Opt_StaticArgumentTransformation)
12891289
-- Static Argument Transformation needs investigation. See #9374
12901290
, ([0,1,2], Opt_SpecEval)
1291-
, ([0,1,2], Opt_SpecEvalDictFun)
1291+
, ([], Opt_SpecEvalDictFun)
12921292
]
12931293

12941294

docs/users_guide/using-optimisation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ as such you shouldn't need to set any of them explicitly. A flag
428428
:category:
429429
:reverse: -fno-spec-eval-dictfun
430430

431-
:default: on
431+
:default: off
432432
:since: 9.14.1
433433

434434
Enables speculative (strict) evaluation of dictionary functions.

testsuite/tests/rts/ipe/T24005/t24005.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ instance Show a => Show (B a) where
3232
main :: IO ()
3333
main = do
3434
-- Should both result in InfoProvs with correct source locations
35-
(\(Box d) -> print =<< whereFrom d) $ mkBox @(Show A)
36-
(\(Box d) -> print =<< whereFrom d) $ mkBox @(Show (B A))
35+
(\(Box !d) -> print =<< whereFrom d) $ mkBox @(Show A)
36+
(\(Box !d) -> print =<< whereFrom d) $ mkBox @(Show (B A))

0 commit comments

Comments
 (0)