|
Boost Users : |
Subject: Re: [Boost-users] Reducing the size of .obj filewhichdoesserialization
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-01-06 12:19:55
Gokulakannan Somasundaram wrote:
> In Release mode, without the BOOST_EXPORT it's around 14MB.
> We have
> decided to keep all of them in one DLL. Similarly we have other DLLs
> (in windows and .so for linux) for other areas of the product. Can
> you please brief me more on separating declarations from definitions.
> We have written the class declarations in .h and the functions to be
> inlined in .inl and the other functions in .cpp.
Sounds like your using the right approach. Basically it boils down to
replacing inline definitions in header files with just declarations and
implementing definitions in cpp and ?ipp files.
Your raw numbers are what bother me. I'm reading for compilations
in release mode:
23 MB for serialization using export
14 MB for serialization non using export
200 classes
I'm assuming the above MB are just the parts related to serialization
and don't include the whole ap. On a per class basis, this boils down
to
115 KB for serialization using export
70 MB for serialization non using export
which seems waaaaaaaayy out of line for me. The tests in the library
don't consume anywhere near that. You should look more carefully
at this. Perhaps making some smaller tests to see where all this
"extra" code is coming from. It might well be that your DLLS
are generating code for ALL the archives that the library supports.
> So the code organization is definitely very clean. Hence i decided to
> put all the serialization code into a separate .cpp file. Is this
> sufficient to use polymorphic_text_archive? The serialization
> actually comes in the non-critical path and hence virtual function
> call is fine for us.
Though it's described in the documentation, here's the short version.
a) your serialization *.cpp files include ONLY polymorphic_?archive.hpp
files. Code is generated against ONLY that interface.
b) Your mainline creates an instance of polymorphic_xml_?archive (or
text or whatever). This is cast to one of its base classes -
polymorphic_?archive.
c) Serialization occurs as normal.
d) Much memory is saved as the serialization code is only instantiated
for polymorphic_?archive.
e) Serialization takes measurable more time. Maybe on the order of 2x?
This could be improved upon by making some implementation changes but
it's not a current priority.
Look into the demos and tests to see examples of how this is done.
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