This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Deduplicate Export before parsing
AbandonedPublic

Authored by takuto.ikuta on Dec 27 2017, 2:41 AM.

Details

Reviewers
ruiu
rnk
Summary

This patch reduces lld link time of chromium's blink_core.dll in
component build.

Total size of input argument in .directives become nearly 300MB in the
build and almost all argument is /EXPORT.

This CL deduplicates exported symbol before parsing.
Original idea of this deduplication for Export is suggested by Rui Ueyama.

On my desktop machine, 4 times stats of the link time are like below.
Improved around 20%.

This patch

TotalSeconds : 10.2710421
TotalSeconds : 9.950322
TotalSeconds : 10.3146625
TotalSeconds : 10.437696
Avg : 10.24343065

master

TotalSeconds : 13.1020911
TotalSeconds : 13.1314426
TotalSeconds : 13.0887463
TotalSeconds : 13.1096681
Avg : 13.107987025

Diff Detail

Event Timeline

takuto.ikuta created this revision.
takuto.ikuta edited the summary of this revision. (Show Details)Dec 27 2017, 3:47 AM
takuto.ikuta added a project: lld.
rnk added a comment.Dec 27 2017, 9:14 AM

I think this is fine, but we should refactor export handling. We already do a lot of work like this in fixupExports, and it would be better if we could move the logic closer together.

lld/COFF/Driver.cpp
1050

StringRef is a value type, it's better to just say StringRef RawE and drop the const &.

1051

Indentation needs fixing.

Fix StringRef type and indent

takuto.ikuta marked 2 inline comments as done.

Thank you for review.
I do not have confidence the way to do good refactoring for export handling.
Can I leave FIXME instead?

ruiu added inline comments.Dec 27 2017, 10:11 PM
lld/COFF/Config.h
109

I think "DirectivesExports" is too narrowly scoped. It should not only contain /EXPORT options appeared in the directives section but also contain /EXPORT options in the command line, because distinguishing the two doesn't make sense. They should be handled in exactly the same way.

lld/COFF/Driver.cpp
1050

I don't like to leave a FIXME comment in the code because in many cases it won't be fixed and just distract people from understanding the code. If you need to fix something, please fix it now.

Merged parsing code.

takuto.ikuta marked 2 inline comments as done.Dec 27 2017, 10:59 PM
ruiu added inline comments.Dec 27 2017, 11:04 PM
lld/COFF/Config.h
109

I'd name this ExportStrings, as RawExports sounds like a new feature or something to me.

lld/COFF/Driver.cpp
1122

I don't think this is correct. You are processing Config->RawExports too early. After this piece of code is executed, there is still a chance that a new file is added to the input file list, and its directive sections won't be processed correctly.

ruiu added a comment.Dec 27 2017, 11:15 PM

I wonder something like this https://reviews.llvm.org/D41607 would work.

Rui-san improved performance with better implementaion in https://reviews.llvm.org/D41607
I close this.

takuto.ikuta abandoned this revision.Dec 27 2017, 11:47 PM