This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Do not parse args twice if no rsp files exists
ClosedPublic

Authored by takuto.ikuta on Dec 26 2017, 3:57 AM.

Details

Summary

This patch reduces 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 no rsp file is used.
Speedup link by skipping duplicate parsing.

On my desktop machine, 4 times stats are like below. Improved around 15%.

This patch

TotalSeconds : 18.408538
TotalSeconds : 17.2996744
TotalSeconds : 17.1053862
TotalSeconds : 17.809777
avg: 17.6558439

master

TotalSeconds : 20.9290504
TotalSeconds : 19.9158213
TotalSeconds : 21.0643515
TotalSeconds : 20.8775831
avg: 20.696701575

Diff Detail

Event Timeline

takuto.ikuta created this revision.Dec 26 2017, 3:57 AM
takuto.ikuta created this object with visibility "takuto.ikuta (Takuto Ikuta)".
takuto.ikuta created this object with edit policy "takuto.ikuta (Takuto Ikuta)".
takuto.ikuta retitled this revision from Do not parse args twice if no rsp files exists to [COFF] Do not parse args twice if no rsp files exists.Dec 26 2017, 4:00 AM
takuto.ikuta added a reviewer: ruiu.
takuto.ikuta changed the visibility from "takuto.ikuta (Takuto Ikuta)" to "Public (No Login Required)".
takuto.ikuta changed the edit policy from "takuto.ikuta (Takuto Ikuta)" to "All Users".
takuto.ikuta added a project: lld.
takuto.ikuta added a subscriber: llvm-commits.
ruiu added a comment.Dec 26 2017, 7:10 PM

Thank you for doing this.

A command line string and .drctive section contents is pretty different. The former may have response files, but the latter shouldn't. The performance of parsing a command line string is not important, so we can always parse the same command line twice.

I'd define a new function, ArgParser::parseDirectives next to ArgParser::parse to parse directives section contents. That should make code cleaner.

Thank you for review.
I made parseDirectives in ArgParser and extend parse() to receive flag for rsp file instead of copying.
How do you think?

ruiu added a comment.Dec 26 2017, 8:50 PM

I still think you should split the function into two. The boolean flag doesn't look beautiful.

lld/COFF/DriverUtils.cpp
735–741

You don't need this for the directive section because the condition will never be true.

744

This is not appropriate for the directive section too.

Sure. Made parseDirectives removing unnecessary codes. Thanks.

takuto.ikuta marked 2 inline comments as done.Dec 26 2017, 9:08 PM
ruiu added inline comments.Dec 26 2017, 9:09 PM
lld/COFF/Driver.h
59–61

Defining two functions for one feature doesn't make much sense. This forwarder function doesn't do anything other than calling tokenize(). Please move that piece of code to the other function and merge the two.

takuto.ikuta marked an inline comment as done.

Merged functions.

ruiu accepted this revision.Dec 26 2017, 9:35 PM

LGTM

This revision is now accepted and ready to land.Dec 26 2017, 9:35 PM

Thank you for review.

I don't have commit access.
Rui-san, can I ask you to merge this patch?

This revision was automatically updated to reflect the committed changes.

(to keep things linked up, this broke building chromium, fixed by inglorion in r321512)

https://bugs.llvm.org/show_bug.cgi?id=35762)