Opened 3 years ago

Closed 7 months ago

#12847 closed bug (duplicate)

ghci -fobject-code -O2 doesn't do the same optimisations as ghc --make -O2

Reported by: nh2 Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.0.1
Keywords: Cc: nh2
Operating System: Other Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

From IRC:

I have a module that takes around 10 seconds to compile on ghc --make -O2, but only around 3 seconds on ghci -fobject-code -O2.

bgamari: that is surprising

I've put the -v timing output of the two cases into https://gist.github.com/nh2/e9bc4732111bfe422d8e606c10f8f0ac

I'm comparing the 2 files with meld for spotting differences easily.

Check e.g. Result size of Tidy Core which seems to have 3x as many terms for ghc, and Simplifier [Mymodule] doesn't seem to run in ghci

The first time terms are different is at Desugar, the first time a factor 3 comes in is after Specialize`.

bgamari: wow, it sounds like the simplifier isn't getting run as aggressively in GHCi

I'm running this on Ubuntu 16.04 inside nix (but happens the same way outside nix).

Change History (3)

comment:1 Changed 3 years ago by rwbarton

Although you don't say so explicitly, you seem to be invoking ghci and then running :set -fforce-recomp -fobject-code -O2 -v at the prompt. Does the same happen with ghci -fforce-recomp -fobject-code -O2 -v?

This could be because of #9370, where decisions about whether to inline a function are effectively made when reading the interface file in which the function is defined; and at that point you may not have -O2 set yet.

comment:2 in reply to:  1 Changed 3 years ago by nh2

Replying to rwbarton:

you seem to be invoking ghci and then running :set -fforce-recomp -fobject-code -O2 -v

I am.

Your guess seems right, if I start ghci on the command line with these flags, it's just as slow as ghc.

comment:3 Changed 7 months ago by RolandSenn

Resolution: duplicate
Status: newclosed

This is the same bug as in #13002. During startup without a -O flag on the command line, GHCi misses to store optimization data (like inline pragmas and rewrite rules). After a :set -O2 this optimization data is missing.

Note: See TracTickets for help on using tickets.