Skip to content

[Build] enable IPO/LTO for release builds#11459

Open
Harmenszoon wants to merge 1 commit into
simulationcraft:midnightfrom
Harmenszoon:codex/perf-cmake-lto
Open

[Build] enable IPO/LTO for release builds#11459
Harmenszoon wants to merge 1 commit into
simulationcraft:midnightfrom
Harmenszoon:codex/perf-cmake-lto

Conversation

@Harmenszoon
Copy link
Copy Markdown
Contributor

Summary

  • add SC_ENABLE_LTO CMake option, default ON
  • use check_ipo_supported() and skip gracefully when IPO/LTO is unavailable
  • enable target-level IPO/LTO for non-Debug builds on engine, simc, and SimulationCraft

Why

CMake Release builds currently use the platform defaults only. On MSVC + Ninja this produced /O2 /Ob2 /DNDEBUG without /GL or /LTCG. A no-code A/B showed that enabling CMake IPO/LTO produces output-equivalent sims with a consistent runtime win.

Validation

Toolchain: Windows, MSVC 19.44.35217.0, CMake 3.31.6, Ninja, BUILD_GUI=OFF.

Initial no-code A/B, same source, baseline Release vs -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON, threads=1 target_error=0 deterministic=1 seed=123456 cleanup_threads=1, 5 interleaved repeats. DPS and TotalEvents matched exactly in all valid cases.

Profile Mean win Median win
profiles/CI.simc iterations=10 5.48% 6.23%
Windwalker DungeonSlice 2000 9.26% 10.65%
Windwalker ST 2000 12.48% 12.21%
Shadow Priest ST 2000 10.40% 10.35%
Havoc DH 5T 2000 8.91% 9.47%
Dev Evoker 5T 2000 9.05% 10.32%

The requested full profiles/CI.simc fight_style=DungeonSlice control is invalid on this checkout because Demon Hunter disables DungeonSlice by default (engine/class_modules/sc_demon_hunter.cpp:11273), and the hinted enable_dungeon_slice=1 is a Demon Hunter actor option rather than a global profile option. I used Windwalker DungeonSlice as the substituted DungeonSlice control.

Final validation on this branch, based on current origin/midnight (cfbfbe4):

  • cmake -S . -B build-pr-lto-off -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=OFF -DSC_ENABLE_LTO=OFF
  • cmake --build build-pr-lto-off --parallel
  • cmake -S . -B build-pr-lto-on -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=OFF
  • cmake --build build-pr-lto-on --parallel

Confirmed SC_ENABLE_LTO=OFF has no /GL or /LTCG; default ON has /GL compile flags and /LTCG link flags. The existing MSVC warning at engine/class_modules/sc_druid.cpp:8909 appears unchanged in both builds.

Final A/B, 5 interleaved repeats:

Profile DPS / TotalEvents Mean win Median win
profiles/CI.simc iterations=10 exact match 5.50% 4.65%
Windwalker ST 2000 exact match 10.66% 10.95%

Risk

  • Release build time increases on my machine: earlier full build comparison was ~36.9s baseline vs ~59.8s IPO.
  • Some packagers may prefer faster local builds or smaller toolchain requirements, so this is opt-out with -DSC_ENABLE_LTO=OFF.
  • Unsupported IPO/LTO toolchains print a status message and continue without enabling IPO/LTO.
  • GUI target has the same target-level property applied, but my local validation was CLI-only with BUILD_GUI=OFF.

…O=OFF)

Adds SC_ENABLE_LTO, default ON, and uses check_ipo_supported() to enable target-level IPO/LTO only for non-Debug configurations. Unsupported toolchains emit a status message and continue without IPO/LTO.

Initial no-code A/B on MSVC 19.44.35217.0, CMake 3.31.6, Ninja, Release BUILD_GUI=OFF compared baseline /O2 /Ob2 /DNDEBUG against IPO /GL + /LTCG with threads=1 target_error=0 deterministic=1 fixed seed. DPS and TotalEvents matched exactly. Mean/median wins: CI_ST_10 5.48/6.23%; Windwalker DungeonSlice 9.26/10.65%; Windwalker ST 12.48/12.21%; Shadow Priest ST 10.40/10.35%; Havoc DH 5T 8.91/9.47%; Dev Evoker 5T 9.05/10.32%.

Build time on that toolchain was 36.9s baseline vs 59.8s IPO. The full CI DungeonSlice profile was invalid because Demon Hunter disables that fight style by default (engine/class_modules/sc_demon_hunter.cpp:11273), so Windwalker DungeonSlice was used as the substituted control.

Patched CMake validation using SC_ENABLE_LTO=OFF vs default ON remained output-equivalent: CI_ST_10 mean/median wins 3.74/4.63%; Windwalker ST 11.45/10.85%. The existing MSVC C4244 warning at engine/class_modules/sc_druid.cpp:8909 was unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant