TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24549 18
New 0-copy deserialization protocol

Hello all! Seems like serialization is a popular topic these days for some reason...

I've posted before about the c++ library "zerialize" (https://github.com/colinator/zerialize), which offers serialization/deserialization and translation across multiple dynamic (self-describing) serialization formats, including json, flexbuffers, cbor, and message pack. The big benefit is that when the underlying protocol supports it, it supports 0-copy deserialization, including directly into xtensor/eigen matrices.

Well, I've added two things to it:

1) Run-time serialization. Before this, you would have to define your serialized objects at compile-time. Now you can do it at run-time too (although, of course, it's slower).

2) A new built-in protocol! I call it "ZERA" for ZERo-copy Arena". With all other protocols, I cannot guarantee that tensors will be properly aligned when 'coming off the wire', and so the tensor deserialization will perform a copy if the data isn't properly aligned. ZERA _does_ support this though - if the caller can guarantee that the underlying bytes are, say, 8-byte aligned, then everything inside the message will also be properly aligned. This results in the fastest 0-copy tensor deserialization, and works well for SIMD etc. And it's fast (but not compact)! Check out the benchmark_compare directory.

Definitely open to feedback or requests!

https://redd.it/1pu6zwe
@r_cpp
GitHub GitHub - colinator/zerialize: Zero-copy multi-format serialization for c++. Zero-copy multi-format serialization for c++. Contribute to colinator/zerialize development by creating an account on GitHub.
More from @r_cpp
  1. Oct 9, 2026std::variant, operator== and pattern matching I was thinking, wouldn't adding equality com…
  2. Oct 8, 2026Profiles for simplicity and guarantees - Bjarne Stroustrup - CppCon 2026 https://youtu.be/…
  3. Oct 8, 2026How to Fix autoconf-style Configuration Probing https://build2.org/blog/fix-autoconf.xhtml…
  4. Oct 8, 2026owl – a header-only C++23 HTTP framework where route patterns and handler extractors are c…
  5. Oct 8, 2026Removed by Reddit Removed by Reddit on account of violating the [content policy. ] https:/…
  6. Oct 8, 2026Is there a way to search across all P and N papers throughout standardization history? It…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →