Skip to content

LLVM Clang is 20% slower than it should be #77975

Closed
@carlocab

Description

@carlocab

brew gist-logs <formula> link OR brew config AND brew doctor output

❯ brew config
HOMEBREW_VERSION: 3.1.9-7-ge2febdf
ORIGIN: https://github.com/Homebrew/brew
HEAD: e2febdfd0796ab04fb87b8b93ce2aed74225dad8
Last commit: 27 minutes ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 2143f2525c1454d09d89f29998e111417969d5ab
Core tap last commit: 42 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_BAT: set
HOMEBREW_BOOTSNAP: set
HOMEBREW_CASK_OPTS: []
HOMEBREW_COLOR: set
HOMEBREW_DEVELOPER: set
HOMEBREW_EDITOR: nvim
HOMEBREW_FORCE_BREWED_CURL: set
HOMEBREW_FORCE_BREWED_GIT: set
HOMEBREW_GITHUB_PACKAGES_TOKEN: set
HOMEBREW_GITHUB_PACKAGES_USER: carlocab
HOMEBREW_GIT_EMAIL: [email protected]
HOMEBREW_GIT_NAME: Carlo Cabrera
HOMEBREW_MAKE_JOBS: 4
HOMEBREW_NO_AUTO_UPDATE: set
HOMEBREW_PRY: set
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: quad-core 64-bit icelake
Clang: 12.0.5 build 1205
Git: 2.31.1 => /usr/local/opt/git/bin/git
Curl: 7.76.1 => /usr/local/opt/curl/bin/curl
macOS: 11.3.1-x86_64
CLT: 12.5.0.22.9
Xcode: N/A

❯ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Putting non-prefixed coreutils in your path can cause GMP builds to fail.

Warning: Putting non-prefixed findutils in your path can cause python builds to fail.

  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.

What were you trying to do (and why)?

Build formulae using LLVM Clang instead of system Clang. This is needed to resolve build failures on Mojave for certain formulae that use C++17 features that haven't been implemented in older versions of Clang.

See, for example: #77819, #77505, #77504, #74765

What happened (include all command output)?

The Mojave nodes systematically took a longer time to complete their runs than the other Intel nodes:

PR Big Sur Catalina Mojave
#77819 31m 41s 29m 32s 34m 59s
#77505 8m 33s 8m 15s 9m 16s
#77504 16m 1s 15m 9s 17m 48s
#74765 1h 1m 38s 55m 44s 40m 11s

This pattern does not hold for #74765 (gRPC) because, at the time of that PR, there were several gRPC-dependent formulae (e.g. mavsdk, bear) that declared depends_on macos: :catalina.

What did you expect to happen?

The Mojave nodes are typically 20-30% faster than the other Intel CI nodes, so I expected Mojave CI to not be slower than the other Intel CI nodes on those PRs.

It's possible that this is just a regression coming from LLVM 12, but I think there are still tweaks we can do with the formula to try to minimise this gap. This is not a regression from LLVM 12. Doing the same exercise with llvm@11 shows an even larger performance gap. See succeeding comments in this issue.

Step-by-step reproduction instructions (by running brew commands)

❯ hyperfine --prepare='brew uninstall hello || true' --warmup=1 --parameter-list compiler clang,gcc,llvm_clang 'brew install -s --cc={compiler} hello'
Benchmark #1: brew install -s --cc=clang hello
  Time (mean ± σ):     54.466 s ±  2.345 s    [User: 31.460 s, System: 23.392 s]
  Range (min … max):   50.691 s … 58.124 s    10 runs

Benchmark #2: brew install -s --cc=gcc hello
  Time (mean ± σ):     55.394 s ±  3.557 s    [User: 31.098 s, System: 23.556 s]
  Range (min … max):   50.850 s … 60.694 s    10 runs

Benchmark #3: brew install -s --cc=llvm_clang hello
  Time (mean ± σ):     65.602 s ±  4.668 s    [User: 35.053 s, System: 28.252 s]
  Range (min … max):   57.526 s … 74.649 s    10 runs

Summary
  'brew install -s --cc=clang hello' ran
    1.02 ± 0.08 times faster than 'brew install -s --cc=gcc hello'
    1.20 ± 0.10 times faster than 'brew install -s --cc=llvm_clang hello'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugReproducible Homebrew/homebrew-core bughelp wantedTask(s) needing PRs from the community or maintainersoutdatedPR was locked due to age

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions