Decreasing Build times

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5502
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1370

Decreasing Build times

Post by dark_sylinc »

I just pushed a new branch v2-2-build-time-opt.

The goal is to try to reduce compilation times on all platforms.

I've been using -ftime-trace; and although it says I've performed impressive optimizations; overall build times have not drastically decreased (includes buildings samples):

Code: Select all

Before Clang9 C++14
real	2m8,344s
user	15m53,879s
sys	0m50,416s

After Clang9 C++14
real	1m58,393s
user	14m40,097s
sys	0m47,608s

Before GCC C++98
real	2m2,504s
user	14m32,773s
sys	1m2,664s

After GCC C++98
real	1m57,145s
user	13m54,947s
sys	1m1,055s

Before GCC C++14
real	3m59,728s
user	29m34,520s
sys	1m39,011s

After GCC C++14
real	3m40,869s
user	27m11,995s
sys	1m30,205s
Note however OgrePrerequisites.h is much lighter (and so is OgreVector3.h etc); so it is quite possible this branch improves build for users of Ogre; and not just building the library.

I wasn't able to benchmark Visual Studio yet (but it compiles fine).

According to time trace, parsing <string> takes a lot of time, so that may benefit from using precompiled headers on all platforms (right now we're only using precompiled headers in Windows)

OK so what?
If you've got further ideas to improve build times, please bring them on here or in the ticket

If you can try the new branch, then please do! It should be stable as I only moved headers around and used a few forward declaration tricks.
But if you have Ogre as a dependency it may break with silly missing header errors.

Let me know what you encounter!
User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 267
Joined: Wed Apr 23, 2014 3:49 pm
Location: Bologna, Italy
x 75

Re: Decreasing Build times

Post by TaaTT4 »

Everything good on my side. I've tested the latest commit (c3752d1) in v2-2-build-time-opt branch and the only drawbacks I encountered are:
  • Include <sstream> where needed
  • Replace snippets of code similar to the one here below:

    Code: Select all

    const NameValuePairList windowParameters
    {
    	{"externalWindowHandle", to_string(reinterpret_cast<uintptr_t>(windowInfo.info.win.window))},
    	{"gamma", renderSystem->getConfigOptions()["sRGB Gamma Conversion"].currentValue},
    	{"vsync", renderSystem->getConfigOptions()["VSync"].currentValue},
    	{"vsyncInterval", renderSystem->getConfigOptions()["VSync Interval"].currentValue}
    };
    
    With:

    Code: Select all

    NameValuePairList windowParameters;
    windowParameters.insert_or_assign("externalWindowHandle", to_string(reinterpret_cast<uintptr_t>(windowInfo.info.win.window)));
    windowParameters.insert_or_assign("gamma", renderSystem->getConfigOptions()["sRGB Gamma Conversion"].currentValue);
    windowParameters.insert_or_assign("vsync", renderSystem->getConfigOptions()["VSync"].currentValue);
    windowParameters.insert_or_assign("vsyncInterval", renderSystem->getConfigOptions()["VSync Interval"].currentValue);
    
    Otherwise I get the following error: 'initializing': cannot convert from 'initializer list' to 'std::map<K,V,P,A>'
Platform Toolset: Visual Studio 2019 (v142)
C++ Language Standard: ISO C++17 Standard (std:c++17)

Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft EsportRacecraft Coin-Op, Victory: The Age of Racing

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5502
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1370

Re: Decreasing Build times

Post by dark_sylinc »

TaaTT4 wrote: Fri Feb 28, 2020 5:56 pm [*]Replace snippets of code similar to the one here below:

Code: Select all

const NameValuePairList windowParameters
{
	{"externalWindowHandle", to_string(reinterpret_cast<uintptr_t>(windowInfo.info.win.window))},
	{"gamma", renderSystem->getConfigOptions()["sRGB Gamma Conversion"].currentValue},
	{"vsync", renderSystem->getConfigOptions()["VSync"].currentValue},
	{"vsyncInterval", renderSystem->getConfigOptions()["VSync Interval"].currentValue}
};
With:

Code: Select all

NameValuePairList windowParameters;
windowParameters.insert_or_assign("externalWindowHandle", to_string(reinterpret_cast<uintptr_t>(windowInfo.info.win.window)));
windowParameters.insert_or_assign("gamma", renderSystem->getConfigOptions()["sRGB Gamma Conversion"].currentValue);
windowParameters.insert_or_assign("vsync", renderSystem->getConfigOptions()["VSync"].currentValue);
windowParameters.insert_or_assign("vsyncInterval", renderSystem->getConfigOptions()["VSync Interval"].currentValue);
That last part is definitely not intended behavior and hopefully fixable.
I'll check what went wrong.
User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 267
Joined: Wed Apr 23, 2014 3:49 pm
Location: Bologna, Italy
x 75

Re: Decreasing Build times

Post by TaaTT4 »

dark_sylinc wrote: Sat Feb 29, 2020 4:17 am That last part is definitely not intended behavior and hopefully fixable.
I'll check what went wrong.
Commit 7e43c27 fixed the issue, thanks.

Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft EsportRacecraft Coin-Op, Victory: The Age of Racing

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5502
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1370

Re: Decreasing Build times

Post by dark_sylinc »

New two commits after new data appeared.

These two changes weren't as intrusive, hence I'm not making a separate branch this time. New timings:

Code: Select all

Clang 9 C++14
real	1m55,995s
user	14m27,704s
sys	0m46,568s

GCC C++14
real	3m33,953s
user	26m35,735s
sys	1m27,774s

GCC C++98
real	1m49,469s
user	13m22,307s
sys	0m57,774s
Btw Clang C++98 is the fastest at only 1m16,497s (1 minute and 16 seconds!!! including samples!) but there's a small issue in Viewport.cpp that prevents compiling with Clang c++98 (I workarounded the issue to do the testing)
chchwy
Kobold
Posts: 30
Joined: Fri Feb 10, 2017 1:40 am
x 11

Re: Decreasing Build times

Post by chchwy »

May I ask what "real", "user", "sys" actually mean?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5502
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1370

Re: Decreasing Build times

Post by dark_sylinc »

Real: the one that matters. Real world times
User: time spent in user space, in all cores (threads?), hence why it's larger than 'real' time. I have a 4 core with 8 threads.
Sys: time spent in kernel space (e.g. IO, thread scheduling, etc)
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 169

Re: Decreasing Build times

Post by xrgo »

its been a while since I haven't updated Ogre in my engine, and I just did a clean built like I always do and its definitely faster, maybe 1/3 of what I remembered, great job!! (win10, VS2017)

Saludos!!