This is an archive of the discontinued LLVM Phabricator instance.

Keep track of canonical decls in Redeclarable.
ClosedPublic

Authored by klimek on Mar 25 2015, 2:44 PM.

Details

Summary

More than 2x speedup on modules builds with large redecl chains.
Between 2-3% cost in memory on large TUs.

Diff Detail

Event Timeline

klimek updated this revision to Diff 22681.Mar 25 2015, 2:44 PM
klimek retitled this revision from to Keep track of canonical decls in Redeclarable..
klimek updated this object.
klimek edited the test plan for this revision. (Show Details)
klimek added a reviewer: rsmith.
klimek added a subscriber: Unknown Object (MLST).

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

Yep, we see a roughly 10x speedup on that test (11 seconds -> 1.1 second)

Test in the bug goes from ~2 seconds to ~300 ms

Testing with normal, larg-ish TUs shows no runtime impact on normal code.

rsmith edited edge metadata.Mar 25 2015, 3:57 PM

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.

rsmith accepted this revision.Mar 25 2015, 4:09 PM
rsmith edited edge metadata.

OK, a 17% speedup for non-modules builds is definitely sufficient to justify a 2-3% increase in memory usage. Thank you!

This revision is now accepted and ready to land.Mar 25 2015, 4:09 PM
klimek closed this revision.Jul 2 2015, 6:47 AM