Quickly Loading Things from Disk
probablydance.com
probablydance.com
Mostly it works if you know the hardware and compiler will stay the same (as in packed struct representation will stay the same). It is basically a poor man's Cap'n'Proto or Flatbuffers.
As for speed, buffering strategy (size and how often fsync is done) will often dominate other stuff. I remember doing a benchmark between C++ and Python for loading and saving data. Python won hands down. The reason was because it had better buffer size defaults. There is also trickery and configuration involved in your page cache params are setup and the schedule of how dirty pages are flushed (if you don't fsync).
> If you’re interested in how fast using read(2) is, it’s essentially the same speed: 5437341 ns if I’m reading directly into the std::vector.
Yap, mmap is not always better, it is more complicated and depending on access pattern not always worth it.
Protobuf solves a completely different problem than 'load a file from disk,' which at least FlatBuffers does.
It seems like the only complaint the author has is that it doesn't work particularly at the level of abstraction they prefer. The FlatBuffers timing results also seem dubious because of the lack of profiling to say what is killing the time. Are the comparisions ruining pipelining? Why not write a transpiler to glue the protobuf output to something you actually want?
It's hard to get past the first half with any confidence in methodology of testing, especially when the author leads with 'Loading things from disk is a surprisingly unsolved problem in C++.'