[PATCH] D19752: ELF: New symbol table design.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 16:48:13 PDT 2016


pcc created this revision.
pcc added reviewers: ruiu, rafael, davide, grimar.
pcc added a subscriber: llvm-commits.
Herald added a subscriber: joker.eph.

This patch implements a new design for the symbol table that stores
SymbolBodies within a memory region of the Symbol object. Symbols are mutated
by constructing SymbolBodies in place over existing SymbolBodies, rather
than by mutating pointers. As mentioned in the initial proposal [1], this
memory layout helps reduce the cache miss rate by improving memory locality.

Performance numbers:

           old(s) new(s)
Without debug info:
chrome      7.178  6.432 (-11.5%)
LLVMgold.so 0.505  0.502 (-0.5%)
clang       0.954  0.827 (-15.4%)
llvm-as     0.052  0.045 (-15.5%)
With debug info:
scylla      5.695  5.613 (-1.5%)
clang      14.396 14.143 (-1.8%)

Performance counter results show that the fewer required indirections is
indeed the cause of the improved performance. For example, when linking
chrome, stalled cycles decreases from 14,556,444,002 to 12,959,238,310, and
instructions per cycle increases from 0.78 to 0.83. We are also executing
many fewer instructions (15,516,401,933 down to 15,002,434,310), probably
because we spend less time allocating SymbolBodies.

The new mechanism by which symbols are added to the symbol table is by calling
add* functions on the SymbolTable. In order to make this work for untemplated
file types such as BitcodeFile, I split SymbolTable into an untemplated base
class and a templated derived class.

In this patch, I handle local symbols by storing them inside "unparented"
SymbolBodies. This is suboptimal, but if we do want to try to avoid allocating
these SymbolBodies, we can probably do that separately.

I also removed a few members from the SymbolBody class that were only being
used to pass information from the input file to the symbol table.

This patch implements the new design for the ELF linker only. Once we're
happy with the new implementation, I intend to prepare a similar patch for
the COFF linker. I have updated the documentation under the assumption that
we will update both linkers, but we can probably land this first.

[1] http://lists.llvm.org/pipermail/llvm-dev/2016-April/098832.html

http://reviews.llvm.org/D19752

Files:
  ELF/Driver.cpp
  ELF/InputFiles.cpp
  ELF/InputFiles.h
  ELF/LTO.cpp
  ELF/MarkLive.cpp
  ELF/OutputSections.cpp
  ELF/SymbolTable.cpp
  ELF/SymbolTable.h
  ELF/Symbols.cpp
  ELF/Symbols.h
  ELF/Writer.cpp
  docs/NewLLD.rst
  test/ELF/lto/common2.ll
  test/ELF/relocation-copy-alias.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19752.55688.patch
Type: text/x-patch
Size: 78148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160429/c8032977/attachment.bin>


More information about the llvm-commits mailing list