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.

The Benchmark That Changed Everything

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 benchmarks
ZAP vs Protobuf benchmark showing 156µs vs 0µs

Platform 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

JSON
2.1µs(17 allocs)
ZAP
3.2ns(0 allocs)
No decode/re-encode needed656x

Consensus Vote

JSON
489ns(1 alloc)
ZAP
0.34ns(0 allocs)
Critical path for blockchain1,438x

State Access

JSON
707µs(11,011 allocs)
ZAP
0.96ns(0 allocs)
mmap random field read736,458x

Batch 100 Messages

JSON
37µs(300 allocs)
ZAP
1.8µs(0 allocs)
Agent tool call batching21x

Warp Message

JSON
20µs(34 allocs)
ZAP
82ns(1 alloc)
Cross-chain decode244x

Validator Set (100)

JSON
28µs(2 allocs)
ZAP
284ns(0 allocs)
Consensus updates99x
Schema Evolution

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 field
Unpacked ZAP1,024 bytes
Protobuf312 bytes
ZAP Packed287 bytes

ZAP packing: smaller than protobuf and still faster

Smart Compression

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.

Security First

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!

Memory Efficiency

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.

17 allocs
JSON per message
0 allocs
ZAP per message
Traditional (100 MCP)825 MB
ZAP Router2.4 MB

Same 100 servers. 341x less memory.

Simple & Expressive

Define your schema once, generate clients for any language.

addressbook.zap
# 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)

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.

341x
less memory
1,438x
faster consensus
0
heap allocations

Ready to go infinitely faster?

Get started with ZAP in minutes. Comprehensive docs cover everything from basic setup to advanced distributed systems patterns.