Hi All,

Following on from a submission that I checked in a couple of days ago
to address performance issues with the Microsoft ostream
implementation poor handling of threaded applications, I have gone a
step further by allow OSG users to disable the notification system
completely.  This is done in a way that enables the compiler to
completely optimize away the OSG_NOTIFY code in the OSG and your own
apps.   The optimization opportunity means a small improvement in
library size (around 1%) and should also result in a little
performance improvement (likely pretty small for most apps unless
hitting upon the said Microsoft ostream threading issues).

To use this new feature use CMakeStep/ccmake to set the
OSG_NOTIFY_DISABLE variable from OFF to ON.  This will in turn
automatically set the include/osg/Config file up to do a #define
OSG_NOTIFY_DISABLE.  Then rebuild the OSG and your app and you should
be able to attempt to output via osg::notify() without ever seeing
anything output.   This is clearly not something you'd want to do in
the dev stage of your application, but when shipping it might be
useful.

For convenience I have also introduced OSG_WARN, OSG_NOTICE, OSG_INFO,
OSG_DEBUG convinience macros that map to OSG_NOTIFY(osg::WARN) etc.
In the OSG code base it would make sense for us to start migrating the
OSG from using osg::notify() across to one of these variants to take
advantage of the optimization trick enabled by the new OSG_NOTIFY
method.  Migrating the OSG across from using osg::notify directly will
steadily improve the size and performance benefits from the
optimization trick so would be worth doing.

If you curious the trick is simply that #define OSG_NOTIFY does:

  if (osg::isNotifyEnabled(level)) osg::notify(level)

Which in itself doesn't do too much, but the next part if that when
OSG_NOTIFY_DISABLE is defined in the build the compiles the
isNotifyEnabled to be inlined and to always return false:

    inline bool isNotifyEnabled(NotifySeverity) { return false; }

So that, for the OSG_NOTIFY entries in the OSG/your code, the compiler
in effect of the sees:

  if (false) osg::notify(level)<<.....

Which should compile away to nothing in an optimized build, and for my
testing under gcc it certainly looks like it does as the code size has
shrunk :-)

Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to