Ogre STD Headers

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Ogre STD Headers

Post by Klaim » Wed Jan 08, 2014 12:06 am

I didn't made yet a deep analysis of the situation but I would like to ask experts and the Ogre team:
Am I correct that the header OgreStdHeaders.h is certainly the biggest source of compilation time in Ogre?
It is included in OgrePrerequisites.h , which is included in almost all Ogre headers, and it have this kind of thing:
#include <fstream>
#include <iostream>
#include <iomanip>
#include <sstream>
I was trying to understand why this header even exist, maybe it was because of a precompiled-header setup, but it looks strange because totally bloated.
0 x

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

Re: Ogre STD Headers

Post by dark_sylinc » Wed Jan 08, 2014 3:01 pm

Ogre needs a session of analyzing all headers and removal of bogus dependencies. But no one's found the time yet, and I don't know about tools in aiding this (AFAIK the boost guys build their own tool to visualize include headers)

It appears to be included in OgrePrerequisites so that the "std headers" get included after all macro settings have been set, mostly to deal with compiler variations i.e.:

Code: Select all

#if (OGRE_COMPILER == OGRE_COMPILER_GNUC) && !defined(STLPORT)
#   if OGRE_COMP_VER >= 430
#       include <tr1/unordered_map>
#elif (OGRE_COMPILER == OGRE_COMPILER_CLANG)
#   if defined(_LIBCPP_VERSION)
#       include <unordered_map>
#   endif
However, IMO including std headers in all files is insane (other than vector and string).
Though I don't think the problem is a single file, but rather that every file ends up including almost every file.
0 x

User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France

Re: Ogre STD Headers

Post by Mikachu » Wed Jan 08, 2014 3:54 pm

A while ago I tried to dig into the problem of Ogre headers, but never quite finished the work...

Here's what I found :
- There's this little tool analysing which header includes what in a C++ project : https://bitbucket.org/bitsquid/header_hero/downloads (but it doesn't perform any analysis about compile time for each header, which could be handy)
- There's massive inclusion between Ogre headers.
One cause for that used to be shared ptrs, as they needed to know the full type of the class they were pointing at.
I submitted a patch for this, but didn't have the time/courage to run an analysis to see what heaer dependencies could be subsequently removed.
- Another cause for massive inclusion is sometimes use of inner typedefs/constants/enums : instead of forward declaring the class in the header, you need to include its header.
- All of that process of improving compile times is a hard task, but would be very useful to the community (compiling Ogre itself is no longer a problem with unity builds, but every project using Ogre get bad compile times because of headers)
0 x
OgreProcedural - Procedural Geometry for Ogre3D

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: Ogre STD Headers

Post by Klaim » Wed Jan 08, 2014 4:30 pm

Interesting points. I'll think for a battle plan to help on this in a few months (when I'll have time a bit more time to apply the plan).
I think it is not natural, even for C++, that Ogre take so much time to build (ignoring the unity build mode).
0 x

User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France

Re: Ogre STD Headers

Post by Mikachu » Wed Jan 08, 2014 4:48 pm

I forgot to say, I'm currently trying to write a pimpl interface generator for Ogre, which would solve those issues from a user point of view, but I'm still not sure I'll succeed (containers/templates of Ogre types don't mix well with the pimpl idiom)
0 x
OgreProcedural - Procedural Geometry for Ogre3D

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: Ogre STD Headers

Post by Klaim » Wed Jan 08, 2014 6:28 pm

Mikachu wrote:I forgot to say, I'm currently trying to write a pimpl interface generator for Ogre, which would solve those issues from a user point of view, but I'm still not sure I'll succeed (containers/templates of Ogre types don't mix well with the pimpl idiom)
Oh wow, that would be very useful!
0 x

Post Reply