Catch 1 code generation much, much slower in release mode than in debug mode on Windows

57 views
Skip to first unread message

Graham Shanks

unread,
Jan 25, 2018, 6:59:50 PM1/25/18
to CATCH
We're using Catch 1.9.4 with a reasonably large test project (39305 assertions in 510 test cases) on Windows using Visual Studio. We have noticed that the code generation step takes a lot longer (10 to 20 minutes) when building in release mode than when building in debug mode (almost instantaneous). We use a range of Visual Studio versions (from VS 2005 through to VS 2015). We also compile under Linux and don't see any noticeable difference in the compile times.

We have a single translation unit that defines CATCH_CONFIG_MAIN and have also defined CATCH_CONFIG_FAST_COMPILE for the complete project.

Any ideas on why release mode is so much slower and on how to fix this?

Martin Hořeňovský

unread,
Jan 26, 2018, 9:00:35 AM1/26/18
to CATCH
Have you tried checking which files take so long?

At a guess, the problem is that VS's Release mode likes using LTO by default, but Catch's main can generate a ton of small functions, that the linker then tries to inline everywhere during the LTCG step. I would try to disable LTCG first, if that doesn't help and the time taken is mostly used up by Catch's main file I would try disabling optimization for that file using optimize pragma (https://msdn.microsoft.com/en-us/library/chh3fb0k.aspx?f=255&MSPPError=-2147217396).

Graham Shanks

unread,
Jan 27, 2018, 3:58:30 PM1/27/18
to CATCH
The linker was taking up all the time (compilation of Catch's main is slow but doesn't take 10 to 20 minutes).

Disabling LTCG fixed the issue (although you need to also turn the GL compilation optimisation off as well, otherwise the linker automatically turns LTCG back on again.

Link time in release mode with GL & LTCG on: 966793 ms
Link time in release mode with GL & LTCG off: 1516 ms

Shaving a whole 16 minutes off the build - result!

Thank you
Reply all
Reply to author
Forward
0 new messages