[all-commits] [llvm/llvm-project] 617d64: Re-land [ThinLTO] Re-order modules for optimal mul...

Alexandre Ganea via All-commits all-commits at lists.llvm.org
Tue Oct 13 18:54:40 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 617d64f6c5f8fdcdacc4401704146247152b96aa
      https://github.com/llvm/llvm-project/commit/617d64f6c5f8fdcdacc4401704146247152b96aa
  Author: Alexandre Ganea <alexandre.ganea at ubisoft.com>
  Date:   2020-10-13 (Tue, 13 Oct 2020)

  Changed paths:
    A lld/test/COFF/thinlto-module-order.ll
    M llvm/include/llvm/LTO/LTO.h
    M llvm/lib/LTO/LTO.cpp
    M llvm/lib/LTO/ThinLTOCodeGenerator.cpp

  Log Message:
  -----------
  Re-land [ThinLTO] Re-order modules for optimal multi-threaded processing

This reverts 9b5b3050237db3642ed7ab1bdb3ffa2202511b99 and fixes the unwanted re-ordering when generating ThinLTO indexes.

The goal of this patch is to better balance thread utilization during ThinLTO in-process linking (in llvm-lto2 or in LLD). Before this patch, large modules would often be scheduled late during execution, taking a long time to complete, thus starving the thread pool.

We now sort modules in descending order, based on each module's bitcode size, so that larger modules are processed first. By doing so, smaller modules have a better chance to keep the thread pool active, and thus avoid starvation when the bitcode compilation is almost complete.

In our case (on dual Intel Xeon Gold 6140, Windows 10 version 2004, two-stage build), this saves 15 sec when linking `clang.exe` with LLD & -flto=thin, /opt:lldltojobs=all, no ThinLTO cache, -DLLVM_INTEGRATED_CRT_ALLOC=d:\git\rpmalloc.

Before patch: 100 sec
After patch: 85 sec

Inspired by the work done by David Callahan in D60495.

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




More information about the All-commits mailing list