Page MenuHomeWildfire Games

Enable link-time optimisation (LTO)
Needs ReviewPublic

Authored by wraitii on Aug 5 2020, 9:17 AM.

Details

Reviewers
Itms
Summary

This changes Premake to use link-time optimisation in release builds.
We probably don't want to patch xCode but just use flto but I wanted to try it and the "embed" trick is good for posterity.

I'm not necessarily expecting huge performance deltas, though ScriptInterface functions might get inlined more readily, which in turn might make some code faster.

Here's a quick 5min Ai-AI replayed game: the LTO seems very slightly faster overall - I'd expect slightly larger deltas on rendering since we have more out-of-line functions there.


Point is, LTO is now a rather mature technology and enabling it seems like a no-brainer on modern compilers. The situation might not be the same on older compilers, so we might want to wait on C++14/17-ready compilers?

Test Plan

Agree / disagree.

Event Timeline

wraitii created this revision.Aug 5 2020, 9:17 AM
Owners added a subscriber: Restricted Owners Package.Aug 5 2020, 9:17 AM
Vulcan added a comment.Aug 5 2020, 9:27 AM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2877/display/redirect

Vulcan added a comment.Aug 5 2020, 9:28 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/2339/display/redirect

wraitii requested review of this revision.Aug 5 2020, 9:40 AM

Does LTO work correctly for old supported compiler? Maybe it should be disabled by default since it might slow down compilation during development.

build/workspaces/update-workspaces.sh
126

Why do you need this line? Also it's duplicating the executable path.

Does LTO work correctly for old supported compiler? Maybe it should be disabled by default since it might slow down compilation during development.

I think once we drop the current "old compilers", i.e. move to C++14 compliant ones, we're mostly in the clear. We could enable LTO only for actual "release" builds though, given that it's a not-completely-negligible perf improvement.

(for that matter, I think we might want an "optimised debug" and a proper "release" compilation settings).

build/workspaces/update-workspaces.sh
126

I don't think I need it, but I thought I did while trying to get things to work (before I realised that scripts.c is tracked)