[serialization] slow compile times with archive register_type
Hi I am using custom archive classes. Problem is BOOST_CLASS_EXPORT_GUID is not working with the custom archive classes, i.e I am getting unregistered class exceptions all over the place, when saving derived class with base pointer. Here is link to my question http://boost.2283326.n4.nabble.com/BOOST-CLASS-EXPORT-GUID-with-custom-archi... about this. So I found other way for exporting the classes, i.e with archive register type. Exporting the classes with register_type is working well, no more unregistered_class exceptions, but probelm is it increase the compile times of my project by more than half. Project compile time with register_type is 40-45 minutes, and without 18-19 minutes. Here is how I am using the register_type : //RegisterMyTypes.h template<class Archive> void register_all_types(Archive&); //RegisterMyTypes.cpp #include "A.h" #include "B.h" // other classes includes template<class Archive> void register_all_types(Archive& a) { ar.register_type (); ar.register_type(); ..... all other classes which is maybe 100 } // explicit instiantion of all my archive classess template void register_all_types(XmlWOArchive& ar); template void register_all_types(XmlWIArchive& ar); template void register_all_types(DbgXmlWOArchive& ar); template void register_all_types(DbgXmlWIArchive& ar); template void register_all_types(BinaryOArchive& ar); template void register_all_types(BinaryIArchive& ar); template void register_all_types(CloneBinaryOArchive & ar); template void register_all_types(CloneBinaryIArchive & ar); template void register_all_types(DuplicateBinaryOArchive & ar); template void register_all_types(DuplicateBinaryIArchive & ar); I am calling register_all_types before doing the serialization/deserialization. And I am doing the serialization/deserialization in multiple functions in my project not just in one place, but this should not be problem, I mean I have the registration done only in one cpp file i.e RegisterMyTypes.cpp, so the templates should be instantiated only in this file, and it should be slow, right ? Thank you for any help -- View this message in context: http://boost.2283326.n4.nabble.com/serialization-slow-compile-times-with-arc... Sent from the Boost - Users mailing list archive at Nabble.com.
Elizabeta wrote
So I found other way for exporting the classes, i.e with archive register type. Exporting the classes with register_type is working well, no more unregistered_class exceptions, but probelm is it increase the compile times of my project by more than half. Project compile time with register_type is 40-45 minutes, and without 18-19 minutes. Here is how I am using the register_type : <snip> I am calling register_all_types before doing the serialization/deserialization. And I am doing the serialization/deserialization in multiple functions in my project not just in one place, but this should not be problem, I mean I have the registration done only in one cpp file i.e RegisterMyTypes.cpp, so the templates should be instantiated only in this file, and it should be slow, right ?
Thank you for any help
No one has every mentioned this before, but then not many people register 100 different data types in the same archive. In any case, once you compile your register types.cpp you ide/makefile should only re-compile it when it changes - which I wouldn't think would be very often so I would not expect this to be an issue. Other than this observation, I can't think what else to say about this. Note: you need only register the types for an archive which that archive is actually going to use. So I'm not sure that making one "register_types.cpp" for all types in the program is going to be a really great idea. I would think that this might slow down execution. Robert Ramey -- View this message in context: http://boost.2283326.n4.nabble.com/serialization-slow-compile-times-with-arc... Sent from the Boost - Users mailing list archive at Nabble.com.
Hi Robert Thank you for your reply. Why putting registration in one cpp file will slow down execution ? -- View this message in context: http://boost.2283326.n4.nabble.com/serialization-slow-compile-times-with-arc... Sent from the Boost - Users mailing list archive at Nabble.com.
the archive register function adds a member to an archive local table. Adding to this table and subsequent usage of the table during lookups might add some time to the serialization/de-serialization process. Then again it might not be significant - only experiment with a profiler could discern this. Actually I would have a greater concern. The sequence of archive register, and serialize statements have to be the same when loading as when the library was saved. If a subsequent version of your program adds an entry to the register.cpp file, then it won't match the information of stored in previously made archives. So they won't be readable. Addressing this would be possible, but also would require extra work. Robert Ramey -- View this message in context: http://boost.2283326.n4.nabble.com/serialization-slow-compile-times-with-arc... Sent from the Boost - Users mailing list archive at Nabble.com.
But if subsequent version of the program adds new entry, that is because new derived class should be serailized via base pointer. So old archives will not be readable anyway. Am I missing something here ? -- View this message in context: http://boost.2283326.n4.nabble.com/serialization-slow-compile-times-with-arc... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Elizabeta
-
Robert Ramey