← the Dry Stack

Zao

Serialization at the speed of memcpy. The fastest zero-allocation encode in .NET.

0.87 ns to encode a 16-byte message. MemoryPack takes 3.11 ns. 268× faster than Protobuf on a 1,024-entity snapshot. 0 B allocated per encode. Protobuf and JSON allocate on every call. 1.4–3.6× ahead of MemoryPack, the only rival within an order of magnitude.
What it is
The piece that turns your data into bytes and back. Tag a struct and a source generator writes the code at build time. For simple types it just copies memory, so the fast path runs at the speed of memcpy.
The problem
Protobuf and JSON walk every field, allocate and encode: real CPU spent on data that is about to be thrown away. Where the layout already matches, Zao charges nothing.
For example
In the F1 replay, every telemetry sample carries a packed blob next to its numeric columns. Zao packs and unpacks those at line rate.
See it move a race →

BenchmarkDotNet, .NET 10, Ryzen 9 7950X3D. Zao writes into a caller-owned buffer with no allocation. MemoryPack and MessagePack get a reused buffer too, so nobody pays for a throwaway array. Lower is better.

Message ZaoWriteTo MemoryPackreused buffer MessagePackreused buffer ProtobufSerialize to [] JSONSerialize to []
PlayerMoved, 16 B blit0.87 ns3.11 ns42 ns141 ns305 ns
SpawnEntity, with string12.5 ns26 ns58 ns143 ns282 ns
Snapshot, 32 entities10.8 ns36.7 ns491 ns1,997 ns8,265 ns
Snapshot, 1024 entities238 ns335 ns14,249 ns63,875 ns254,741 ns
Inventory, 128-key map1.65 µs3.18 µs2.74 µs8.20 µs3.49 µs

Only MemoryPack stays within an order of magnitude, and it still trails by 1.4 to 3.6 times. MessagePack is 4 to 60 times back. Protobuf and JSON are one to three orders behind, and they have no zero-allocation path at all.

Where Zao doesn't win. It isn't the smallest on the wire: MessagePack's varint packing beats it on small, integer-heavy messages. On decode Zao is fastest across the board and allocates less for value-type messages (72 B against 128 B on SpawnEntity), but collection-heavy messages force everyone to build the same arrays, maps and strings, so memory ties.

The table reads from the BenchmarkDotNet rows for Zao's *_Encode and the rivals' *_EncodeReuse, Windows 11 on a Ryzen 9 7950X3D. The full summary also covers decode, wire sizes and allocations.

show raw output ↓captured 22 June 2026, unedited
Want Zao in your system?

We're taking a few early users. If serialization shows up in your profiles, tell us what you'd build. You get Zao and direct help; we get your feedback.

info@drylane.io
Zao is part of the Dry Stack, built by Drylane.