Serialization at the speed of memcpy. The fastest zero-allocation encode in .NET.
memcpy.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 blit | 0.87 ns | 3.11 ns | 42 ns | 141 ns | 305 ns |
| SpawnEntity, with string | 12.5 ns | 26 ns | 58 ns | 143 ns | 282 ns |
| Snapshot, 32 entities | 10.8 ns | 36.7 ns | 491 ns | 1,997 ns | 8,265 ns |
| Snapshot, 1024 entities | 238 ns | 335 ns | 14,249 ns | 63,875 ns | 254,741 ns |
| Inventory, 128-key map | 1.65 µs | 3.18 µs | 2.74 µs | 8.20 µs | 3.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.
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.
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