[PATCH] Speculatively instantiate archive members

Rui Ueyama ruiu at google.com
Fri Jan 16 07:36:09 PST 2015


Hi Bigcheese, kledzik, atanasyan, compnerd, shankarke,

LLD parses archive file index table only at first. When it finds a symbol
it is looking for is defined in a member file in an archive file, it actually
reads the member from the archive file. That's done in the core linker.

That's a single-thread process since the core linker is single threaded.
If your command line contains a few object files and a lot of archive files
(which is quite often the case), LLD hardly utilizes hardware parallelism.

This patch improves parallelism by speculatively instantiating archive
file members. At the beginning of the core linking, we first create a map
containing all symbols defined in all members, and each time we find a
new undefined symbol, we instantiate a member file containing the
symbol (if such a file exists). File instantiation is side effect free, so this
should not affect correctness.

This is a quick benchmark. Time to link self-link LLD executable:

Linux   9.78s -> 8.50s (0.86x)
Windows 6.18s -> 4.51s (0.73x)

http://reviews.llvm.org/D7015

Files:
  include/lld/Core/ArchiveLibraryFile.h
  include/lld/Core/File.h
  include/lld/Core/Resolver.h
  lib/Core/Resolver.cpp
  lib/ReaderWriter/FileArchive.cpp
  lib/ReaderWriter/PECOFF/ReaderCOFF.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7015.18302.patch
Type: text/x-patch
Size: 9338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150116/7998887f/attachment.bin>


More information about the llvm-commits mailing list