ZAP Protocol

Benchmarks

Real-world performance benchmarks for ZAP Protocol across AI agents, blockchain VMs, and distributed systems.

Benchmarks

ZAP is designed for the most demanding use cases in AI and crypto infrastructure. These are real benchmarks measured on Apple M1 Max.

The Infinity Benchmark

ZAP vs Protobuf benchmark

This benchmark measures encoding/decoding round-trip time in memory. ZAP achieves 0µs because there is no encoding step — the in-memory format IS the wire format.

"But that's unfair!" — Yes, that's the point. ZAP eliminates the problem entirely.


Measured Results

All benchmarks run on Apple M1 Max with Go 1.25 and Python 3.14. Run them yourself →

Serialization Performance

OperationJSONZAPSpeedupJSON AllocsZAP Allocs
Tool call encode385ns18ns21x20
Tool call decode1,746ns31ns56x151
Round-trip2,142ns48ns45x171
Message routing2,122ns3.2ns656x170
Batch 100 messages37µs1.8µs21x3000
Large message (32KB)37µs4.6µs8x21

Blockchain & Consensus

OperationJSONZAPSpeedupJSON AllocsZAP Allocs
Warp message encode3.7µs53ns70x20
Warp message decode20µs82ns244x341
Consensus vote489ns0.34ns1,438x10
1000 attestations421µs1.8µs234x20
Validator set (100)28µs284ns99x20
Random state access707µs0.96ns736,458x11,0110

AI Agent Communication

ScenarioJSON-RPCZAPSpeedup
20 agents × 50 tool calls12.48ms6.21ms2x
Per-call latency9.64µs3.56µs2.7x
Memory (100 MCP servers)825 MB2.4 MB341x

Distributed Inference

OperationJSONZAPSpeedup
KV cache shard (1MB)22.6ms0.024ms926x
Batch prompts (32×512)4,049µs20µs200x
Speculative decode verify5.46µs0.026µs210x

Memory Efficiency

ZAP's arena allocation and zero-copy access provide consistent memory behavior:

MetricJSONZAPImprovement
Allocations per message170-194% reduction
100 MCP server overhead825 MB2.4 MB99.7% reduction
Memory fragmentationHighNoneEliminated
GC pressureSevereMinimalPredictable latency
Cache localityPoorExcellentFaster access

Why Memory Matters

Traditional JSON-RPC with 100 MCP servers:

  • Each server: separate process (~8MB)
  • Pipe buffers: ~256KB per connection
  • Per-message allocations: 17 heap allocs
  • Total: 825 MB just for connections

ZAP with single router:

  • One router process (~2MB)
  • Shared arena buffer (64KB)
  • Per-message allocations: 0
  • Total: 2.4 MB for same 100 servers
Claude Code (100 MCP): ████████████████████████████████████████ 825 MB
Hanzo ZAP Router:      █ 2.4 MB

341x less memory. Same functionality.

Memory-Mapped Files

ZAP files can be memory-mapped for instant access to any field:

// Map a 10GB state file
data, _ := mmap.Open("blockchain_state.zap")
defer data.Close()

// Access any field instantly — OS pages in only what you touch
account := state.Root().Accounts().Get(address)
balance := account.Balance()  // Only this 4KB page is loaded

// JSON would require parsing all 10GB first

Measured: 707µs (JSON parse + access) vs 0.96ns (ZAP mmap access) = 736,458x faster


Zero Allocations

The key to ZAP's performance isn't just speed—it's zero heap allocations.

JSON encode:     2 allocs/op    272 B/op
ZAP encode:      0 allocs/op      0 B/op  ← No heap activity

JSON decode:    15 allocs/op    640 B/op
ZAP decode:      1 allocs/op     48 B/op  ← Just the result slice

JSON batch 100: 300 allocs/op   30KB/op
ZAP batch 100:    0 allocs/op      0 B/op  ← Arena reuse

Why this matters:

  • No GC pauses: Zero allocations = zero garbage collection
  • Predictable latency: No surprise GC stalls in hot paths
  • Better cache utilization: Data stays in L1/L2 cache
  • Linear scaling: Batch operations don't multiply allocations

Code Size

ZAP generates minimal code compared to other formats:

FormatGenerated code (1000 types)
Protobuf~2.5 MB
FlatBuffers~1.8 MB
ZAP~150 KB

Smaller generated code means:

  • Faster compilation
  • Smaller binaries
  • Better instruction cache utilization
  • Easier auditing

Methodology

Test Environment

  • CPU: Apple M1 Max (10 cores)
  • Memory: 32GB unified
  • OS: macOS 14
  • Go: 1.25.6
  • Python: 3.14.2

What We Measure

Encoding time: Time to convert in-memory structures to wire format.

  • JSON: json.Marshal() call
  • ZAP: Direct struct pack to buffer

Decoding time: Time to make wire data accessible.

  • JSON: json.Unmarshal() + field access
  • ZAP: Pointer arithmetic + bounds check

Allocations: Heap allocations per operation.

  • Measured via Go's testing.B.ReportAllocs()
  • Critical for GC-sensitive workloads

The "Unfair" Advantage

ZAP benchmarks look unfair because they are. Traditional formats force you to:

  1. Serialize — Convert memory to bytes
  2. Transmit — Send bytes over network/IPC
  3. Deserialize — Parse bytes back to memory

ZAP eliminates steps 1 and 3. The wire format IS the memory format.

This isn't cheating — it's better engineering.


Run Your Own Benchmarks

# Clone the benchmark suite
git clone https://github.com/zap-protocol/benchmarks
cd benchmarks

# Install dependencies
make setup

# Run all benchmarks
make bench

# Run specific benchmark suite
make bench-serialize    # Go serialization
make bench-blockchain   # Warp messaging, consensus
make bench-agents       # MCP, multi-agent
make bench-inference    # Distributed AI

Results are written to results/ in JSON format.

See the benchmark repository for full methodology and reproducible results.

On this page