building clang llvm efficiently
play

Building Clang/LLVM efficiently Tilmann Scheller LLVM Compiler - PowerPoint PPT Presentation

Building Clang/LLVM efficiently Tilmann Scheller LLVM Compiler Engineer t.scheller@samsung.com Samsung Open Source Group Samsung Research UK EuroLLVM 2015 London, United Kingdom, April 13 14, 2015 Samsung Open Source Group 1 Overview


  1. Building Clang/LLVM efficiently Tilmann Scheller LLVM Compiler Engineer t.scheller@samsung.com Samsung Open Source Group Samsung Research UK EuroLLVM 2015 London, United Kingdom, April 13 – 14, 2015 Samsung Open Source Group 1

  2. Overview ● Introduction ● Performance ● Summary Samsung Open Source Group 2

  3. Introduction Samsung Open Source Group 3

  4. Introduction ● Clang/LLVM are large pieces of C++ software ● Long turnaround time harms developer productivity ● Squeeze maximum performance out of the toolchain ● Speed up the build without buying new hardware ● Focus on x86-64 Linux ● Test machine: Fedora 21 on i7-4770K CPU @ 3.50GHz, 16GB RAM, 1TB 7200RPM HDD Samsung Open Source Group 4

  5. Ideas ● Build with Clang instead of GCC ● Only build what you really need (e.g. only build relevant backends) ● Use a faster linker: GNU gold instead of GNU ld ● Use a heavily optimized compiler binary for the build (LTO, PGO, LTO+PGO) ● For incremental debug builds: shared library build instead of static build Samsung Open Source Group 5

  6. Performance Samsung Open Source Group 6

  7. Measurement ● GCC 4.9.2 shipping with Fedora 21 ● Clang trunk snapshot (r234392 from April 8, 2015) ● Standard debug/release builds of Clang (CMake build with default generator) unless otherwise noted ● Using GNU gold 2.24 for linking ● Make invoked with -j8 ● Best of five runs Samsung Open Source Group 7

  8. Clang vs. GCC compile time ● Both Clang and GCC are compiled with GCC 4.9.2 755 Debug build 1.48x faster 509 Clang GCC 4.9.2 726 Release build 1.34x faster 538 0 100 200 300 400 500 600 700 800 seconds Samsung Open Source Group 8

  9. Only build a subset of Clang/LLVM ● Only build relevant backends ● Host Clang built with GCC 4.9.2 755 1.27x faster Debug build 591 X86 backend only All backends 726 Release build 1.24x faster 583 0 100 200 300 400 500 600 700 800 seconds Samsung Open Source Group 9

  10. Use a faster linker ● Using GNU gold instead of GNU ld ● Building Clang with GCC 4.9.2 873 1.17x faster Debug build 755 746 GNU gold + split DWARF GNU gold 731 GNU ld Release build 726 0 100 200 300 400 500 600 700 800 900 1000 seconds Samsung Open Source Group 10

  11. Optimize host compiler binary aggressively Building Clang with a heavily optimized host Clang build ● Host Clang was compiled with Clang or GCC at the various different ● optimization levels Release Debug 560 520 512 547 510 509 538 537 540 498 500 522 520 480 500 467 482 seconds 480 seconds 460 450 462 460 440 440 420 420 400 400 GCC -O3 GCC LT O GCC LT O+PGO GCC -O3 GCC LT O GCC LT O+PGO Clang -O3 Clang LT O GCC PGO Clang -O3 Clang LT O GCC PGO PGO 1.16x faster PGO 1.13x faster Samsung Open Source Group 11

  12. Speeding up incremental builds Shared library build rather than static build ● Debug build of Clang with GCC 4.9.2 ● Incremental build after changing a single file in the ARM backend ● (ARMISelLowering.cpp) 27 Build time after edit Shared build Static build 5 5.4x faster 0 5 10 15 20 25 30 seconds Samsung Open Source Group 12

  13. Summary Samsung Open Source Group 13

  14. Summary ● Always build with Clang if you care about compile time ● Use GNU gold rather than GNU ld ● Building Clang with GCC and PGO produces fastest binary ● Shared library builds speed up incremental debug builds tremendously ● Overall speedup: 1.58x for release builds and 1.94x for debug builds (Switching from GCC + GNU ld to a PGO build of Clang + GNU gold) Samsung Open Source Group 14

  15. Thank you. Samsung Open Source Group 15

Recommend


More recommend