More than 2x speedup on modules builds with large redecl chains.
Between 2-3% cost in memory on large TUs.
Details
- Reviewers
rjmccall rsmith doug.gregor
Diff Detail
Event Timeline
I think this fixes
https://llvm.org/bugs/show_bug.cgi?id=10651
My previous attempt was to invert the link order, but that is a lot
more involved.
An interesting testcase:
#define M extern int a;
#define M2 M M #define M4 M2 M2 #define M8 M4 M4 #define M16 M8 M8 #define M32 M16 M16 #define M64 M32 M32 #define M128 M64 M64 #define M256 M128 M128 #define M512 M256 M256 #define M1024 M512 M512 #define M2048 M1024 M1024 #define M4096 M2048 M2048 #define M8192 M4096 M4096 #define M16384 M8192 M8192 M16384
I think it's worth a 2-3% memory increase to remove this as a source of pathological performance problems. See also https://llvm.org/bugs/show_bug.cgi?id=21264 which would also be fixed by this change (that bug suggests an alternative, much more complex, strategy if the 2-3% memory increase isn't acceptable).
Some of my measurements were wrong (testing a assertion enabled release
build against a real opt build), but it gets even better:
For one of our large TUs, this brings non-module compile time down from 36
-> 30 seconds.
OK, a 17% speedup for non-modules builds is definitely sufficient to justify a 2-3% increase in memory usage. Thank you!