Skip to content

CONCEPT Cited by 1 source

Zero-copy parsing

Definition

Zero-copy parsing is the technique of extracting structured data from a serialized byte stream without allocating new memory buffers or copying bytes out of the original network/disk buffer. Parsed fields reference directly into the source buffer via offsets or pointers. The parser's output is valid only while the source buffer remains alive — a lifetime constraint that languages like Rust can enforce at compile time.

Why it matters

At high-throughput data paths (multi-GB/s), memory allocation and copying become the bottleneck:

  • Allocation pressure triggers GC pauses (in managed languages) or fragmention (in unmanaged).
  • Copies consume memory bandwidth and pollute CPU caches.
  • Object construction for deserialized messages scales linearly with message count.

Zero-copy parsing eliminates all three, enabling single-core throughput at or near memory bandwidth limits.

Key properties

  1. Single-pass: bytes traversed exactly once.
  2. No intermediate representation: no deserialized object graph in memory.
  3. Buffer lifetime dependency: parsed views are only valid while the source buffer is held.
  4. Language support: most naturally expressed in Rust (lifetimes), C/C++ (raw pointers), or via memory-mapped I/O in any language.

Seen in

Last updated · 542 distilled / 1,571 read