-
Notifications
You must be signed in to change notification settings - Fork 813
Description
With CEREAL_THREAD_SAFE enabled, we observed performance peaked in our application (while not with Boost serialization library). With the option disabled, the bottle neck are removed.
As far as I can see by reading the code, the mutex / lock is used in two user cases - versioning support and polymorphic class serialization. We don't use the latter hence focus on the former in the issue.
At the first time one class has been serialized, Cereal library will record its version number in a global map and serialize that. That is fine. But Cereal locks the map in every serialization seems not necessary. For example, to allow multiple readers by std::shared_mutex might improve a little bit.
Further more, our application follows share-nothing patter between threads. As our threads are long-time living, I think it would work with thread-local versioning map instead of singleton class. I am not sure if this is common for others.
One more question, our current workaround is disable CEREAL_THREAD_SAFE and force to register all class to be serialized (by serializing all classes) before application started. Is that safe? Anything I am missing?