[PATCH] D123879: [LLD] Alternate implementation for "Support per-thread allocators and StringSavers"

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 15 15:40:34 PDT 2022


aganea created this revision.
aganea added reviewers: MaskRay, oontvoo, mstorsjo, int3.
Herald added subscribers: StephenFan, arichardson, emaste.
Herald added a project: All.
aganea requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is an alternate implementation based on @oontvoo's D122922 <https://reviews.llvm.org/D122922>.

The main differences are:

- `LLD_THREAD_SAFE_MEMORY` was removed
- `AllocContext` is always thread-local.
- Using `llvm::sys::ThreadLocal` to make TLS allocation dynamic at runtime. This is to accommodate for several instances of `CommonLinkerContext` running concurrently.
- No "safe" or "perThread" functions, the APIs remain the same as before.

I did not see any divergence in performance when using a two-stage LLD, built with `-DLLVM_INTEGRATED_CRT_ALLOC=rpmalloc`, with ThinLTO & `-march=native`.

Chromium's chrome.dll:

  D:\git\chromium\src\out\Default>hyperfine "d:\git\llvm-project\stage2_rpmalloc\bin\_globalbump\lld-link.exe @__link_chrome_dll.rsp" "d:\git\llvm-project\stage2_rpmalloc\bin\_tlbump\lld-link.exe @__link_chrome_dll.rsp"
  Benchmark 1: d:\git\llvm-project\stage2_rpmalloc\bin\_globalbump\lld-link.exe @__link_chrome_dll.rsp
    Time (mean ± σ):     10.971 s ±  0.037 s    [User: 0.001 s, System: 0.001 s]
    Range (min … max):   10.913 s … 11.044 s    10 runs
  
  Benchmark 2: d:\git\llvm-project\stage2_rpmalloc\bin\_tlbump\lld-link.exe @__link_chrome_dll.rsp
    Time (mean ± σ):     10.974 s ±  0.050 s    [User: 0.000 s, System: 0.001 s]
    Range (min … max):   10.908 s … 11.072 s    10 runs
  
  Summary
    'd:\git\llvm-project\stage2_rpmalloc\bin\_globalbump\lld-link.exe @__link_chrome_dll.rsp' ran
      1.00 ± 0.01 times faster than 'd:\git\llvm-project\stage2_rpmalloc\bin\_tlbump\lld-link.exe @__link_chrome_dll.rsp'

Chromium's unit_tests.exe:

  D:\git\chromium\src\out\Default>hyperfine "d:\git\llvm-project\stage2_rpmalloc\bin\_globalbump\lld-link.exe @__link_unit_tests.rsp" "d:\git\llvm-project\stage2_rpmalloc\bin\_tlbump\lld-link.exe @__link_unit_tests.rsp"
  Benchmark 1: d:\git\llvm-project\stage2_rpmalloc\bin\_globalbump\lld-link.exe @__link_unit_tests.rsp
    Time (mean ± σ):     17.512 s ±  0.197 s    [User: 0.001 s, System: 0.001 s]
    Range (min … max):   17.311 s … 17.933 s    10 runs
  
  Benchmark 2: d:\git\llvm-project\stage2_rpmalloc\bin\_tlbump\lld-link.exe @__link_unit_tests.rsp
    Time (mean ± σ):     17.509 s ±  0.080 s    [User: 0.001 s, System: 0.003 s]
    Range (min … max):   17.387 s … 17.658 s    10 runs
  
  Summary
    'd:\git\llvm-project\stage2_rpmalloc\bin\_tlbump\lld-link.exe @__link_unit_tests.rsp' ran
      1.00 ± 0.01 times faster than 'd:\git\llvm-project\stage2_rpmalloc\bin\_globalbump\lld-link.exe @__link_unit_tests.rsp'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123879

Files:
  lld/Common/CommonLinkerContext.cpp
  lld/Common/Memory.cpp
  lld/ELF/Symbols.h
  lld/include/lld/Common/CommonLinkerContext.h
  lld/include/lld/Common/Memory.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123879.423179.patch
Type: text/x-patch
Size: 6832 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220415/eba50c37/attachment.bin>


More information about the llvm-commits mailing list