Monday 30 May 2011

Developer Journal 89 - On Boost Serialization


So I'm re-enabling serialization bit by bit after turning it all off. I'm trying to determine what's causing the compiling and linking steps to take so long.

Okay, so serializing one class, the top level class, SimData, takes 4 seconds to link.

Serializing class Object. 4 seconds to link.

Serializing class Vector. 4 seconds to link.

Exporting class SimData. 5 seconds to link.

Exporting class Object. 5 seconds to link.

Serializing class Food. 5 seconds to link.

Exporting class Food. 5 seconds.

Serializing class Synapse. 5 seconds.

Serializing class Neuron. 4 seconds.

Serializing class NeuronGroup. 7 seconds.

Serializing class Brain. 4 seconds.

Serializing class Genome. 4 seconds.

Serializing class Robot. 6 seconds.

Exporting class Brain. 23 seconds.

Exporting class NeuronGroup. 17 seconds.

Exporting class Neuron. 17 seconds.

Exporting class Synapse. 18 seconds.

Exporting class Robot. 26 seconds.

Exporting class Genome. 29 seconds.

Somehow it's jumped to 35 seconds.

Now 3 seconds because I disabled including the binary archive headers.

Back to 36 seconds.

30 seconds.

4 seconds if I don't include the binary archive headers.

Am I supposed to include the binary archive headers in each file that has a serialization function?

Tomorrow I'll switch from BOOST_CLASS_EXPORT() to BOOST_CLASS_EXPORT_KEY() and BOOST_CLASS_EXPORT_IMPLEMENT().

I also want to move to rely less on Boost Serialization. That means I want to handle pointers and containers myself for a start.

I included the binary archive headers in two places and the link time jumped to 48 seconds. Looks like you're only supposed to include them in one place.

I turned off all serialization and export code and included the binary archive headers in only one place.

3 seconds to link.

I suspect that each archive type you include adds 30 seconds to the compile time and 30 seconds to the link time. Link time jumped to 124 seconds when I included the binary and text archives.

Including the text archive takes a long compiling time and 61 seconds to link.

The binary archive takes 55 seconds to link. Strange, the link times have all gone up.

The file that includes the archive header takes about 45 seconds to compile and 86 seconds to link.

I think everything is taking a bit longer because I re-enabled to code in the serialization functions.

At least now I can toggle the archive includes and be able to work much more quickly.

The file with the binary archive header takes 44 seconds to compile and the whole link process takes 74 seconds.

Strange. I switched from BOOST_CLASS_EXPORT() in Serializer.cpp with binary archive includes and the link time went from 30 to 15 seconds.

Also the link time time does not go up if I include the binary archive in other implementation files. It does not like it if I include the binary archives in other header files though.

Switching from BOOST_CLASS_EXPORT() in one implementation file with binary archive includes to BOOST_CLASS_EXPORT_KEY() and BOOST_CLASS_EXPORT_IMPLEMENT() has halved compiling and linking times to 20 seconds and 15 seconds respectively. That's 20 seconds for the one implementation with the binary archive includes.

This should be the last developer journal entry on Boost Serialization. From here it's about applying the saving and loading to the graphics and physics engines.

Hmm. In Serializer.cpp I included the binary archives but I also have to include all the classes that I serialize. This doesn't make sense because any change in the classes that I serialize means that I have to re-compile Serializer.cpp and that takes a long time.

To fix it, I have to include the binary archive in the files that I do the BOOST_CLASS_IMPLEMENT()? Nope, that didn't work.

Frustratingly, a change in classes that I serialize will generate a re-compilation of class Serializer which can take from 21 to 51 seconds. At least the link times are down to less than 15 seconds.

Frak! I'm getting an error when I serialize!

I tried a whole bunch of combinations but I don't think BOOST_CLASS_IMPLEMENT() is working.

Looks like I'm going to have to put up with up to 51 seconds compile times and up to 51 second link times.

compile - 31 seconds
link - 48 seconds

Hmm. The less BOOST_CLASS_EXPORT() the faster the compiling and linking. But not by much.

RELATED

No comments:

Post a Comment