Opened 6 years ago

Last modified 3 years ago

#7443 infoneeded bug

Generated C code under -prof -fprof-auto -fprof-cafs very slow to compile

Reported by: orenbenkiki Owned by:
Priority: normal Milestone:
Component: Profiling Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

Some background: This is C code generated when I turned on profiling with -fprof-auto -fprof-cafs, on Haskell code that contains a large amount of injected TemplateHaskell code. GHC takes several minutes to compile this on its side; but for some reason it emits the attached C code, which (if compiled with -O) takes "forever" to compile. At least, I killed it after consuming 3 hours of CPU and occupying 9GB of RAM.

I also opened a GCC bug for this; but a cursory look seems to indicate this C code is trying to build a linked list in memory, which it seems should be doable in a much more straightforward way. In fact since the list of CAFs will not change in run-time, it should be possible to initialize it in compile time as:

ENTRY entry_0[1] = { ..., link = NULL };
ENTRY entry_1[1] = { ..., link = entry_0 };
...
head = entry_n;

And this is before wondering why not use an array of entries instead of a linked list in the 1st place. That said, I am just guessing here, I have no understanding of what is really going on, other than the fact I was forced to add {-# OPTIONS_GHC -optc -O0 #-} to the offending file.

Attached is a tgz file containing the generated C code (plus a version which is post-CPP, so you can just try to compile it in various ways on systems without GHC installed).

Attachments (1)

SLOW_GCC.tar.bz2 (225.6 KB) - added by orenbenkiki 6 years ago.
TGZ file containing the generated C code and the RUN cc1 command line

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by orenbenkiki

Attachment: SLOW_GCC.tar.bz2 added

TGZ file containing the generated C code and the RUN cc1 command line

comment:1 Changed 6 years ago by igloo

Description: modified (diff)
difficulty: Unknown

comment:2 Changed 6 years ago by igloo

Component: CompilerProfiling
Milestone: 7.8.1

Thanks for the report. We'll take a look.

comment:3 Changed 5 years ago by thoughtpolice

Milestone: 7.8.37.10.1

Moving to 7.10.1

comment:4 Changed 4 years ago by thomie

Status: newinfoneeded

I had a look at the files in the attached zip file. There is a RUN script with hard coded directory paths that don't exist on my system, two .hscpp that import a module called Haski that I can't find on hackage, and a giant c that is supposedly giving you troubles.

As it stands, your problem is rather hard to reproduce. Could you please make a smaller, self-contained, example?

comment:5 Changed 4 years ago by orenbenkiki

Well... it has been a while since I submitted the original report and my code base has mutated and grown a lot since then. It is a pretty large project and contains information I can't release out of my company...

The question seems to be why the generated code builds the linked list dynamically rather than as static initializers, this "should" be unrelated to the inputs... right?

comment:6 Changed 4 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:7 Changed 3 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:8 Changed 3 years ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.