[Boost-bugs] [Boost C++ Libraries] #2563: [boost][serialization] void_upcast is very slow

Subject: [Boost-bugs] [Boost C++ Libraries] #2563: [boost][serialization] void_upcast is very slow
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-12-04 07:44:18


#2563: [boost][serialization] void_upcast is very slow
---------------------------------+------------------------------------------
 Reporter: jacobholm_at_[hidden] | Owner: ramey
     Type: Feature Requests | Status: new
Milestone: Boost 1.38.0 | Component: serialization
  Version: Boost 1.37.0 | Severity: Optimization
 Keywords: |
---------------------------------+------------------------------------------
 My preference would be to detect mulitple inheritance at compile time
 if that's possible.

 Make a TRAK ticket for this item.

 Robert Ramey

 '''''Jacob wrote:'''
 The original "inline void_upcast" method checks if the pointer to the
 object is of the right type, by traversing its parents. This is necessary
 when using multiple inheritance, since in such a case the adress of the
 pointer to the object can vary depending on which base class it is cast
 to.''

 ''While profiling one of my projects I noticed that most of the time was
 spent in the void_upcast method. I modified the method to return the
 pointer directly(see below), resulting in a high performance increase.
 This "solution" is possible if you avoid multiple inheritance all
 together, which I did. In my particular project I experienced a 75% speed
 increase implementing this, going from about 10 seconds to 2.5 seconds.''

 ''Would it be possible to implement some functionality to turn on and off
 the upcasting for given classes, kind of like the tracking of objects is
 currently administrated?''

 ''Modified "inline void_upcast":''

 {{{
 /inline void *
 void_upcast(
   extended_type_info const & derived,
   extended_type_info const & base,
   void * const t
 ){
    return const_cast<void*>(t);
  }/
 }}}


 ''Yours sincerely,''

 ''Jacob Holm''

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2563>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC