[all-commits] [llvm/llvm-project] a24418: [CodeLayout] cache-directed sort: limit max chain ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Sun Oct 22 16:50:16 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a24418375a707b7314e7687888dd02eaefca42cd
      https://github.com/llvm/llvm-project/commit/a24418375a707b7314e7687888dd02eaefca42cd
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-10-22 (Sun, 22 Oct 2023)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/CodeLayout.h
    M llvm/lib/Transforms/Utils/CodeLayout.cpp
    M llvm/unittests/Transforms/Utils/CodeLayoutTest.cpp

  Log Message:
  -----------
  [CodeLayout] cache-directed sort: limit max chain size (#69039)

When linking an executable with a slightly larger executable,
ld.lld --call-graph-profile-sort=cdsort can be very slow (see #68638).
```
   4.6%  20.7Mi    .text.hot
   3.5%  15.9Mi    .text
   3.4%  15.2Mi    .text.unknown
```

Add cl option `cdsort-max-chain-size`, which is similar to
`ext-tsp-max-chain-size`, and set it to 128, to improve performance.

In `ld.lld @response.txt --threads=4 --call-graph-profile-sort=cdsort
--time-trace"
builds, the "Total Sort sections" time is measured as follows:

* -mllvm  -cdsort-max-chain-size=64: 1.321813
* -mllvm -cdsort-max-chain-size=128: 2.030425
* -mllvm -cdsort-max-chain-size=256: 2.927684
* -mllvm -cdsort-max-chain-size=512: 5.493106
* unlimited: 9 minutes

The rest part takes 6.8s.




More information about the All-commits mailing list