[all-commits] [llvm/llvm-project] da68d2: [ELF] Cap parallel::strategy to 16 threads when --...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Apr 12 13:13:51 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: da68d2164efcc1f5e57f090e2ae2219056b120a0
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-04-12 (Wed, 12 Apr 2023)

  Changed paths:
    M lld/ELF/Driver.cpp

  Log Message:
  [ELF] Cap parallel::strategy to 16 threads when --threads= is unspecified

When --threads= is unspecified, we set it to
`parallel::strategy.compute_thread_count()`, which uses
sched_getaffinity (Linux)/cpuset_getaffinity (FreeBSD)/std::thread::hardware_concurrency (others).
With extensive testing on many machines (many configurations from
{aarch64,x86-64} x {Linux,FreeBSD,Windows} x allocators(native,mimalloc,rpmalloc) combinations)
with varying workloads, we discovered that when the concurrency is larger than
16, the linking process is slower than using --threads=16 due to parallelism
overhead outweighs optimizations. This is particularly harmful for machines with
many cores or when the link job competes with other jobs.

Cap parallel::strategy when --threads= is unspecified.
For some workloads changing the concurrency from 8 to 16 has nearly no improvement.

--thinlto-jobs= is unchanged since ThinLTO backend compiles are embarrassingly

Link: https://discourse.llvm.org/t/avoidable-overhead-from-threading-by-default/69160

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D147493

More information about the All-commits mailing list