Compiling profiling CCS registration .c file takes far too long
When compiling executables for profiling, ghc generates a .c file something like this:
#define IN_STG_CODE 0
#include "Rts.h"
#include "Stg.h"
static void prof_init_Main(void) __attribute__((constructor));
static void prof_init_Main(void)
{extern CostCentre Foo_bar_cc[];
REGISTER_CC(Foo_bar_cc);
...
When there are a large number of CCSs, e.g. 10's of 1,000s (as can easily happen with large projects and using -fprof-auto) then of course this .c file and this single C function become very large. The C compiler then takes a very long time to compile it.
For example, with a .c file with ~27k lines (so about half that number of CCSs), gcc 4.7.2 with -O1 takes about 20 minutes to compile. With -O0 it takes about 4 seconds. Clearly this version of gcc does not cope very well with this massive function at -O1 level.
I suggest that since the initialisation is not performance critical, and it doesn't look like there is a lot to optimise here anyway, that ghc compile this .c file without passing gcc the -O flag.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |