Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] speed & size optimized binary archive
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-12-04 16:54:53


Sebastian Karlsson wrote:
> I'm trying to create a binary archive which manages serialization of
> derived type through base and archive versioning ( not on a type by
> type basis ). Looking at the binary archive which ships with the
> distribution it serializes a whole lot of things which is unnecessary
> for our use case.

like what? archives don't contain anything that doesn't have to
be there in order to restore the data.

> Going by the documentation and looking on how other archives are
> implemented I've created a basic implementation, which while compiling
> doesn't handle serialization of exported types. Even though the
> documentation is mostly great, this is a small area which seems to be
> left out, namely the requirements of an archive to be able to
> serialize / deserialize exported types properly.

all you have to do is to include boost/serialization/export.hpp

> Looking at the
> provided archive types it's not clearly distinguishable exactly what's
> needed for this functionality. The documentation mentions
> BOOST_SERIALIZATION_REGISTER_ARCHIVE, which is used for the archive.

> Also, it would be great to know more in depth what actually gets
> serialized, even if it's subject of change for newer versions. For
> example, I'm interested in knowing how serialization of exported types
> will impact archive size. I'm thinking just an extra id per instance?
> Reading the documentation I got a hunch that extra meta data on a per
> type basis gets serialized to the archive as well. Under "Types used
> by the serialization library" several types are mentioned, which of
> these can be ignored for our use case?

The easiest way to find this stuff out is to serialize your data to an
xml_oarchive.
This labels all the data with descriptive tags and the structure is
very apparent.

> This is a reduced form of the output archive which together with an
> analogous input archive doesn't manage to serialize derived types
> through their base even if exported, checked to work with the supplied
> binary archive type.

I don't see any advantage at all to this effort. The beauty of
template meta programming is that only the code actually used
is generated. Let the compiler do the work.

The headers in the library are almost all optional. For example,
If you're not going to serialize derived types - don't include
boost/serialization/base_objec.hpp. etc. This way you
absolutely know you're not generating code that
corresponds to facilities benig used.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net