Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1418: polymorphic archive performance improvement
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-26 20:23:03
#1418: polymorphic archive performance improvement
-------------------------------------------+--------------------------------
Reporter: Kim Barrett <kab@â¦> | Owner: ramey
Type: Patches | Status: assigned
Milestone: To Be Determined | Component: serialization
Version: Boost 1.34.1 | Severity: Optimization
Resolution: | Keywords:
-------------------------------------------+--------------------------------
Comment (by Kim Barrett <kab@â¦>):
The following discussion is with respect to boost 1.43. I haven't
checked whether there are any relevant changes in more recent versions
of boost.
The proposed implementation of archive_cast involves some relatively
intrusive changes to base_iarchive and base_oarchive to record the
cached archive caster and cached archive pointer. The reason for this
is that there is no common base class between polymorphic_[i,o]archive
and the non-polymorphic-archive implementation archives.
polymorphic_iarchive_impl derives only from
detail::interface_iarchive<polymorphic_iarchive>.
polymorphic_iarchive derives only from polymorphic_iarchive_impl.
binary_iarchive derives from binary_iarchive_impl<binary_iarchive, ...>.
binary_iarchive_impl<Archive, ...> derives from
basic_binary_iprimitive<Archive, ...> and
basic_binary_iarchive<Archive>.
basic_binary_iarchive<Archive> derives from
detail::common_iarchive<Archive>.
detail::common_iarchive<Archive> derives from
detail::basic_iarchive and from detail::interface_iarchive<Archive>.
So there are no common base classes between polymorphic_iarchive and
binary_iarchive.
If there were such a common base class (which would have to be a
virtual base class on both inheritance branches), then the
archive_cast conversion could consist of implicit up-conversion from
the non-polymorphic-archive implementation class to that common base
class, and then a static (or dynamic when debugging) down-cast to the
polymorphic-archive class.
The obvious place to put such a common base class would be to add a
virtual non-template base class to detail::interface_iarchive<>. This
would make detail::interface_iarchive polymorphic (as in
boost::is_polymorphic<>, not to be confused with the
polymorphic-archive classes), which it presently isn't, so there is
some cost there.
[Note that the detail::interface_iarchive<> non-virtual default destructor
is
presently public, which is probably a mistake. And the default public
copy
constructor and assignment operator are also present here, which also
seems
like a mistake. I think a polymorphic_iarchive can improperly be copied
or
assigned.]
A different attachment point for such a common virtual base class
would be basic_iarchive and polymorphic_iarchive_impl, both of which
are already polymorphic.
If it is a base class for detail::interface_iarchive<> then the
obvious name is detail::basic_interface_iarchive, and it provides no
functionality (beyond non-public default constructor, non-public
destructor, and suppressed copy constructor and assignment operator).
Not sure what the name should be if the attachment point is at the
polymorphic_iarchive_impl and base_iarchive layer. Also likely
requires more documentation there. Presently, all archives derive
from detail::interface_iarchive<>, though perhaps that really is an
implementation detail.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/1418#comment:7> 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:50:04 UTC