ZAP
Infinitely faster.
An insanely fast data interchange format and capability-based RPC system.
Think JSON, except binary. Think Protocol Buffers, except faster. In benchmarks, ZAP is INFINITY TIMES faster.
Why INFINITY times faster?
This benchmark is, of course, unfair. It only measures the time to encode and decode a message in memory.
ZAP gets a perfect score because there is no encoding/decoding step.
The ZAP encoding is appropriate both as a data interchange format AND an in-memory representation, so once your structure is built, you can simply write the bytes straight out to disk!
See all benchmarksPlatform Independent
The encoding is defined byte-for-byte independent of any platform. However, it is designed to be efficiently manipulated on common modern CPUs.
Struct-like Layout
Fixed widths, fixed offsets, proper alignment — just like a compiler would arrange it
Pointer-based
Variable-sized elements embedded as offset pointers for position independence
Position Independent
Pointers are relative, not absolute — messages can live anywhere in memory
Little-endian
Most CPUs are little-endian, and big-endian CPUs have conversion instructions
Real Numbers. Real Impact.
Measured on Apple M1 Max. Run them yourself.
Message Routing
Consensus Vote
State Access
Batch 100 Messages
Warp Message
Validator Set (100)
Backwards Compatible
New fields are always added to the end of a struct (or replace padding space), so existing field positions are unchanged.
The recipient simply needs to do a bounds check when reading each field.
Fields are numbered in the order they were added, so ZAP always knows how to arrange them for automatic backwards-compatibility.
# Version 1
struct User
name Text
email Text
# Version 2 - fully compatible!
struct User
name Text
email Text
phone Text # New field
verified Bool # New fieldZAP packing: smaller than protobuf and still faster
Doesn't fixed-width waste space?
Yes, fixed-width integers, unset optional fields, and padding do add zeros on the wire.
However, since all these extra bytes are zeros, ZAP applies an extremely fast packing scheme to remove them.
ZAP packing achieves similar (better, even) message sizes to protobuf encoding — and it's still faster.
When bandwidth really matters, apply general-purpose compression (zlib, LZ4) on top of any format.
Isn't this horribly insecure?
No no no! To be clear, we're NOT just casting a buffer pointer to a struct pointer.
ZAP generates classes with accessor methods that you use to traverse the message. These accessors validate pointers before following them.
If a pointer is invalid (e.g. out-of-bounds), the library can throw an exception or simply replace the value with a default / empty object — your choice.
ZAP checks structural integrity just like any other serialization protocol. And just like any other protocol, it's up to the app to check content validity.
Battle-Tested Security
- Powers Hanzo AI's distributed inference infrastructure
- Used in Lux Network's consensus layer
- Undergone fuzzing and expert security review
- Environments where security is paramount
Superpowers
Are there other advantages? Glad you asked!
Incremental Reads
Start processing a ZAP message before you have received all of it — outer objects appear entirely before inner objects.
Random Access
Read just one field of a message without parsing the whole thing. Jump directly to the data you need.
Memory Mapping
Read a large ZAP file via mmap. The OS won't even read in the parts that you don't access.
Inter-Language Communication
Java, Python, C++, Rust — all can operate on the same in-memory data structure. No slow serialization between languages.
Inter-Process Communication
Multiple processes share ZAP messages via shared memory. No kernel pipes. Process calls as fast as thread calls.
Arena Allocation
ZAP objects are always allocated in an arena or region style — faster than scattered allocations and promotes cache locality.
Tiny Generated Code
Usually no more than inline accessor methods! Order of magnitude smaller than protobuf's parsing/serialization code.
Tiny Runtime Library
Due to the simplicity of the ZAP format, the runtime library can be much smaller. Less code to ship, audit, and maintain.
Time-Travel RPC
ZAP's RPC system implements promise pipelining — call results return to clients before requests even arrive at the server!
99.7% Less Memory
Running 100 MCP servers with traditional JSON-RPC? That's 825 MB of memory overhead.
With ZAP routing through a single server? Just 2.4 MB.
ZAP's arena allocation means zero heap allocations per message. No GC pressure. No fragmentation. Predictable latency.
Same 100 servers. 341x less memory.
Simple & Expressive
Define your schema once, generate clients for any language.
# ZAP schema - clean, whitespace-significant syntax
struct Person
name Text
email Text
birthdate Date
phones List(PhoneNumber)
struct PhoneNumber
number Text
type PhoneType
enum PhoneType
mobile
home
work
interface AddressBook
lookup (id UInt64) -> (person Person)
search (query Text) -> stream (person Person)Get Started
From zero to production in four steps
Common Questions
But doesn't that mean the encoding is platform-specific?
NO! The encoding is defined byte-for-byte independent of any platform. Data is arranged like a compiler would arrange a struct — with fixed widths, fixed offsets, and proper alignment. Variable-sized elements are embedded as pointers. Pointers are offset-based rather than absolute so that messages are position-independent.
Won't fixed-width integers waste space on the wire?
Yes, fixed-width integers, unset optional fields, and padding do add zeros. However, ZAP applies an extremely fast packing scheme to remove them. ZAP packing achieves similar (better, even) message sizes to protobuf — and it's still faster. For bandwidth-critical paths, apply general compression (zlib, LZ4) on top.
Isn't directly accessing binary data insecure?
To be clear: we're NOT just casting a buffer pointer to a struct pointer. ZAP generates classes with accessor methods that validate pointers before following them. Invalid pointers (out-of-bounds, etc.) throw exceptions or return defaults. ZAP checks structural integrity just like any other serialization protocol.
How does backwards compatibility work?
New fields are always added to the end of a struct (or replace padding). Existing field positions never change. Recipients do bounds checking when reading. Fields are numbered by addition order, so ZAP always knows how to arrange them for compatibility.
What languages are supported?
ZAP has implementations for C++, Rust, Go, TypeScript/JavaScript, Python, Java, and C#. The schema language and wire format are language-agnostic. Code generation produces type-safe bindings for your target language.
Production Proven
ZAP powers Hanzo AI's distributed inference infrastructure and Lux Network's consensus layer — environments where microseconds matter and security is paramount.
Ready to go infinitely faster?
Get started with ZAP in minutes. Comprehensive docs cover everything from basic setup to advanced distributed systems patterns.