RobRich999 / Chromium_Clang

Chromium browser compiled with the Clang/LLVM compiler.
157 stars 10 forks source link

LTO opts and haswell #32

Closed Alex313031 closed 1 year ago

Alex313031 commented 1 year ago

HIIIIIIIIII!!

Also, why are you setting the lto opt level to 2 instead of 3?

Also, since you are setting -march=haswell in the avx2 configs, this also sets -mtune=haswell since setting march with no mtune sets mtune to the same. This is undesirable since the avx2 builds might run on a variety of hardware, and would actually be more likely to run on a ryzen or skylake+ system considering haswell's age. You might want to set -mtune to generic alongside it.

RobRich999 commented 1 year ago

Upon analysis of multiple benchmark runs, LTO codegen at O3 offers no appreciable benefit over O2 for the Chromium codebase, though it can increase build times.

Haswell is considered the baseline scheduling model for AVX2-class processors in LLVM. You can set other models if desired, but the reality is the Haswell scheduling model is generally accepted as the "baseline best compromise" across multiple platforms supporting AVX2, FMA3, etc. By setting other models, you could be impairing performance on other platforms, along with pulling in instructions that might be optimized on Intel or not AMD and vice versa. YMMV.

https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86.td

If ya' want to start splitting up AMD. Intel, etc. optimized builds, go for it. I just do not have the time, effort, or energy to bother, especially when the real-world performance difference is likely to be a couple or so percent. We are not dealing with enterprise or HPC workloads here. ;)

Using /arch:AVX2 with clang-cl maps to -march=haswell as well.

https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Arch/X86.cpp

If you are seeing -mtune=haswell or similar in any of my code, it is because I am building that code on AVX hardware that does not natively support AVX2, but I still want the underlying instruction tuning model to be the same.

I assume you are talking about the following in my Win64 AVX2 cross build:

"-Ctune-cpu=haswell", "-Ctarget-feature=+avx,+aes,+vaes",

Not that any Rust code is likely run natively during the build, but just in case considering I have not bothered checking, I simply set -mtune=haswell instead of -march=haswell because those builds are being done on older AMD Opteron systems that do no support AVX2. Conversely, I can get away with /arch:AVX2 (-march=haswell) for the Windows code being built, as I know none of it is actually run during the build. ;)