Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Issue 10808021: Change LLVM bitcode linking to use tree reduction to scale better (Closed)

Created:
8 years, 5 months ago by jvoung (off chromium)
Modified:
8 years, 4 months ago
CC:
native-client-reviews_googlegroups.com
Visibility:
Public.

Description

Change LLVM bitcode linking to use tree reduction rather than link in one at a time. Linking one at a time means that the "Dst" module keeps growing yet needs to be crawled entirely at each step to gather a set of types. The cost becomes something 1 + 2 + 3 + ... + N (quadratic). Instead, delay linking until we know of all the modules so we can do linking as a tree. The actual linking is now done when the module-getter is called, and error messages are also delayed till then. Time before for linking llc.pexe: ~126 secs Time after for linking llc.pexe: ~20 secs Memory after for linking llc.pexe: ~1GB for 727 modules. ~1.3GB if we don't delete the sources as they are consumed. NOTE: a separate "opt" pass can still take 1.5 min for llc, so LTO optimized builds can still take a while, but at least non-optimized builds can be faster. BUG= http://code.google.com/p/nativeclient/issues/detail?id=2883 TEST= rebuild.

Patch Set 1 #

Patch Set 2 : Different version (change way gold-plugin uses interface, rather than hack the scoped pointers) #

Total comments: 8

Patch Set 3 : Added comments #

Total comments: 1

Patch Set 4 : stuff #

Unified diffs Side-by-side diffs Delta from patch set Stats (+126 lines, -7 lines) Patch
M llvm/include/llvm-c/lto.h View 1 2 1 chunk +19 lines, -0 lines 0 comments Download
M llvm/tools/gold/gold-plugin.cpp View 1 2 4 chunks +20 lines, -3 lines 0 comments Download
M llvm/tools/llc/llc.cpp View 1 1 chunk +3 lines, -3 lines 0 comments Download
M llvm/tools/lto/LTOCodeGenerator.h View 1 2 3 chunks +10 lines, -0 lines 0 comments Download
M llvm/tools/lto/LTOCodeGenerator.cpp View 1 2 3 1 chunk +62 lines, -0 lines 0 comments Download
M llvm/tools/lto/lto.cpp View 1 2 2 chunks +10 lines, -1 line 0 comments Download
M llvm/tools/lto/lto.exports View 1 2 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
jvoung (off chromium)
still testing, but at least smoke tests pass
8 years, 5 months ago (2012-07-18 21:38:31 UTC) #1
jvoung - send to chromium...
On 2012/07/18 21:38:31, jvoung (chromium) wrote: > still testing, but at least smoke tests pass ...
8 years, 5 months ago (2012-07-19 00:08:11 UTC) #2
jvoung (off chromium)
On 2012/07/19 00:08:11, jvoung wrote: > On 2012/07/18 21:38:31, jvoung (chromium) wrote: > > still ...
8 years, 5 months ago (2012-07-24 21:42:05 UTC) #3
jvoung (off chromium)
Newer version, now that arm self-build works. Some data: ~jvoung/linktimes.before ~jvoung/linktimes.after to see the diff ...
8 years, 4 months ago (2012-08-01 00:02:41 UTC) #4
robertm
LGTM neat! some requests for more commenting below http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGenerator.cpp File llvm/tools/lto/LTOCodeGenerator.cpp (right): http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGenerator.cpp#newcode106 llvm/tools/lto/LTOCodeGenerator.cpp:106: bool ...
8 years, 4 months ago (2012-08-01 14:02:31 UTC) #5
robertm
One more question: is it essential that we only merge adjacent modules? On 2012/08/01 14:02:31, ...
8 years, 4 months ago (2012-08-01 14:28:38 UTC) #6
jvoung (off chromium)
http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGenerator.cpp File llvm/tools/lto/LTOCodeGenerator.cpp (right): http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGenerator.cpp#newcode106 llvm/tools/lto/LTOCodeGenerator.cpp:106: bool LTOCodeGenerator::gatherModule(LTOModule* mod) { On 2012/08/01 14:02:31, robertm wrote: ...
8 years, 4 months ago (2012-08-01 17:11:01 UTC) #7
robertm
8 years, 4 months ago (2012-08-01 17:24:37 UTC) #8
LGTM (still)

On 2012/08/01 17:11:01, jvoung (chromium) wrote:
>
http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGener...
> File llvm/tools/lto/LTOCodeGenerator.cpp (right):
> 
>
http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGener...
> llvm/tools/lto/LTOCodeGenerator.cpp:106: bool
> LTOCodeGenerator::gatherModule(LTOModule* mod) {
> On 2012/08/01 14:02:31, robertm wrote:
> > gather is no a very specific term.
> > Maybe add a comment or use a better function name:
> > e.g. :
> > // Add module to list of modules which are part of the "linked" image.
> > // Note: the link does not happen right away but is delayed 
> > // so that we can optimize this rather costly step
> 
> renamed to gatherModuleForLink(), but yeah, not sure what is best.  Added some
> comments though.
> 
>
http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGener...
> llvm/tools/lto/LTOCodeGenerator.cpp:111: // We gather the asm undefs earlier
> than addModule() does,
> On 2012/08/01 14:02:31, robertm wrote:
> > since the llvm folks did not seem to have commented this asm undef stuff.
> > Could you describe in a comment what you have learned about that.
> 
> Added some comments.  Hopefully this is a constant array that is not modified
by
> merging.  It looks like it is a "char*" of some global's name coming straight
> from ASM, so that shouldn't be interpreted and changed by llvm???
> 
>
http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGener...
> llvm/tools/lto/LTOCodeGenerator.cpp:124: // will be Module 0.
> On 2012/08/01 14:02:31, robertm wrote:
> > not sure whether this adds all that much:
> > After the first round (stride = 1) only modules with even index are still
> there,
> > after the second round (stride = 2) only the modules with indices divisible
by
> 4
> > are still there, etc. 
> > 
> > 
> > If you can find some algorithmic reference that would be even better. 
> > Also say that we disregard module sizes for now.
> 
> Done.
> 
>
http://codereview.chromium.org/10808021/diff/5001/llvm/tools/lto/LTOCodeGener...
> llvm/tools/lto/LTOCodeGenerator.cpp:127: while (stride < len) {
> On 2012/08/01 14:02:31, robertm wrote:
> > why not use a for loop here as well
> 
> Done.
> 
>
http://codereview.chromium.org/10808021/diff/10001/llvm/tools/gold/gold-plugi...
> File llvm/tools/gold/gold-plugin.cpp (right):
> 
>
http://codereview.chromium.org/10808021/diff/10001/llvm/tools/gold/gold-plugi...
> llvm/tools/gold/gold-plugin.cpp:134: gather_then_link = false;
> changed this flag to be "no-gather-..." so that one could turn it back to the
> original behavior, since I had set it on by default.

Powered by Google App Engine
This is Rietveld 408576698