This is an archive of the discontinued LLVM Phabricator instance.

Call _exit
ClosedPublic

Authored by rafael on Oct 26 2016, 9:52 AM.

Details

Summary

As the state of lld gets more complicated, shutting down gets more expensive.

In a normal lld run we can just call _exit immediately after renaming the temporary output file. We still want the ability to run a full shutdown since that is useful for detecting memory leaks.

The attached patch adds a --full-shutdown flag and changes lit to use it.

The speedups I got were

firefox

master 7.230308488
patch  7.208082567 1.00308347203x faster

firefox-gc

master 7.427749933
patch  7.418814415 1.00120444016x faster

chromium

master 5.205103172
patch  5.125736748 1.01548390561x faster

chromium fast

master 2.049300081
patch  1.969078119 1.04074087322x faster

the gold plugin

master 0.355730113
patch  0.349688155 1.01727813171x faster

clang

master 0.600935753
patch  0.59087035 1.01703487576x faster

llvm-as

master 0.034656451
patch  0.034052431 1.01773794065x faster

the gold plugin fsds

master 0.386335917
patch  0.378535563 1.02060666094x faster

clang fsds

master 0.686066136
patch  0.672882627 1.01959258342x faster

llvm-as fsds

master 0.032056437
patch  0.031330437 1.02317235473x faster

scylla

master 3.24018577
patch  3.232975627 1.00223018786x faster

This also makes sure we don't have to worry to much about the shutdown cost of future changes.

Diff Detail

Event Timeline

rafael updated this revision to Diff 75910.Oct 26 2016, 9:52 AM
rafael retitled this revision from to Call _exit.
rafael updated this object.
rafael added a reviewer: ruiu.
rafael added a subscriber: llvm-commits.
emaste added a subscriber: emaste.Oct 26 2016, 9:58 AM

Nifty idea

ELF/Options.td
83

need a better description :)

ruiu added inline comments.Oct 26 2016, 10:10 AM
ELF/Driver.cpp
55

Instead of propagating CanExitEarly, you can set Config->ExitEarly before calling this function.

ELF/Writer.cpp
326

Is even exit() expensive? If you use exit() instead of _exit(), you don't need to flush the streams.

rafael edited edge metadata.

Update docs and set Config variable earlier.

ruiu accepted this revision.Oct 26 2016, 11:48 AM
ruiu edited edge metadata.

LGTM with these changes. As a record, we are doing the same thing for the COFF LLD.

ELF/Options.td
83

Please use F<> instead of Flag<> because we should accept both -full-shutdown and --full-shutdown .

ELF/Writer.cpp
323

Please add a comment that we exit as soon as we finished writing the output file to avoid the cost of destructors which gives us a few percent performance improvement.

This revision is now accepted and ready to land.Oct 26 2016, 11:48 AM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL285224. Please specify "Differential revision: <URL>" as last line of commit message.

Could quick_exit() be used instead?

ruiu added a comment.Nov 11 2016, 1:19 PM

What is better in quick_exit than _exit?

In D25997#593232, @ruiu wrote:

What is better in quick_exit than _exit?

It calls functions registered with at_quick_exit().
e.g. it could call llvm_shutdown().