Opened 3 years ago

Closed 3 years ago

#13395 closed bug (invalid)

3x slowdown on GHC HEAD with file containing lots of overloaded string literals

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

Description

I just noticed that compiling xmlhtml-0.2.3.5 from Hackage takes an extraordinarily long time on GHC HEAD. The slowdown can be attributed to the Text.XmlHtml.HTML.Meta module. I've extracted it and tweaked it so that it requires no dependencies to build (I now use ByteString instead of Text, but the slowdowns for both types were about the same.)

On GHC 8.0.2, it takes about 3 seconds to compile the attached module:

$ /usr/bin/time /opt/ghc/8.0.2/bin/ghc -fforce-recomp TextXmlHtmlHTMLMeta.hs 
[1 of 1] Compiling Text.XmlHtml.HTML.Meta ( TextXmlHtmlHTMLMeta.hs, TextXmlHtmlHTMLMeta.o )
3.44user 0.07system 0:03.51elapsed 99%CPU (0avgtext+0avgdata 208480maxresident)k
0inputs+21688outputs (0major+43934minor)pagefaults 0swaps

But on GHC HEAD, it takes about 10 seconds:

$ /usr/bin/time ~/Software/ghc2/inplace/bin/ghc-stage2 -fforce-recomp TextXmlHtmlHTMLMeta.hs 
[1 of 1] Compiling Text.XmlHtml.HTML.Meta ( TextXmlHtmlHTMLMeta.hs, TextXmlHtmlHTMLMeta.o )
9.93user 0.11system 0:10.03elapsed 100%CPU (0avgtext+0avgdata 233656maxresident)k
0inputs+21464outputs (0major+54853minor)pagefaults 0swaps

Attachments (1)

TextXmlHtmlHTMLMeta.hs (61.7 KB) - added by RyanGlScott 3 years ago.

Download all attachments as: .zip

Change History (4)

Changed 3 years ago by RyanGlScott

Attachment: TextXmlHtmlHTMLMeta.hs added

comment:1 Changed 3 years ago by simonpj

That's bad! But it's so egregiously bad that surely it ought not to be hard to find where the time is going!

Ben, Reid, David: might one of you look? If we can fix this we may fix other less-egregious cases.

Simon

comment:2 Changed 3 years ago by rwbarton

I took a look but on my systems it doesn't compile in anywhere near 3.5 seconds under GHC 8.0.2. It takes about 15 seconds for me and a recent (but not absolutely up-to-date) HEAD is similar. RyanGlScott are you sure about these numbers?

comment:3 Changed 3 years ago by RyanGlScott

Resolution: invalid
Status: newclosed

Ugh, it turns out this was caused by me using a GHC HEAD that was built with the quick flavor instead of the perf flavor. I had thought that the only difference between the two was that the latter built Haddocks and other non-essentials—that couldn't have been more wrong!

After rebuilding GHC HEAD with perf, I get this time:

$ /usr/bin/time ~/Software/ghc4/inplace/bin/ghc-stage2 -fforce-recomp TextXmlHtmlHTMLMeta.hs
[1 of 1] Compiling Text.XmlHtml.HTML.Meta ( TextXmlHtmlHTMLMeta.hs, TextXmlHtmlHTMLMeta.o )
3.08user 0.07system 0:03.17elapsed 99%CPU (0avgtext+0avgdata 196820maxresident)k
0inputs+21464outputs (0major+41873minor)pagefaults 0swaps

Which is even better than 8.0.2! So this tale had a happy ending after all.

Note: See TracTickets for help on using tickets.