cereal icon indicating copy to clipboard operation
cereal copied to clipboard

[feature request] Support mmap backend for BinaryInputArchive in Linux/Unix/Android platform

Open fengwang opened this issue 9 months ago • 1 comments

I serialized my LLM model with cereal, the serialized model size starting from 3GB, and the weight loading time does matter to the performance.

With this test program (https://raw.githubusercontent.com/lemire/Code-used-on-Daniel-Lemire-s-blog/refs/heads/master/2012/06/26/ioaccess.cpp), I found on my Linux system mmap could read 389M integers per second, but c++ istream could only read 196M.

I would therefore like to check if it possible to add a mmap backend for BinaryInputArchive if the target platform is Unix-like.

fengwang avatar Mar 05 '25 21:03 fengwang

If your stdlib has std::spanstream you can create a memory mapping and create a spanstream on that and then pass the spanstream to cereal. It's not as good as direct memory mapping but should be faster than std::ifstream.

h-2 avatar Jul 24 '25 15:07 h-2