Skip to content

Add zero-copy framed telemetry ingestion with buffer-pool backpressure #87

Merged
elizabetheonoja-art merged 5 commits into
Utility-Protocol:mainfrom
real-venus:Zero-Copy-Frame-Backpressure
Jun 26, 2026
Merged

Add zero-copy framed telemetry ingestion with buffer-pool backpressure #87
elizabetheonoja-art merged 5 commits into
Utility-Protocol:mainfrom
real-venus:Zero-Copy-Frame-Backpressure

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

Telemetry Stream Ingestion Memory Backpressure with Zero-Copy Binary Frames (#33)

Closes #33

What's added (src/ingestion/)

Module Responsibility
buffer_pool.rs BufferPool — a Semaphore-gated recycling pool (default 1024 × 64 KB = 64 MB). acquire() awaits when all buffers are in flight (backpressure to the reader instead of unbounded allocation); released buffers are recycled, so the steady-state allocation rate is ~0 (exposed via allocation_count()).
frame_parser.rs read_frame() reads the u32 BE length prefix, validates length ≤ MAX_FRAME_SIZE before reading, then read_exact()s exactly length bytes into a pooled buffer. CBOR is decoded zero-copy straight from the pooled slice (ciborium::de::from_reader, no per-frame Vec).
stream_handler.rs handle_stream() — bounded frame loop dispatching each frame to a callback (buffer recycled on drop). An oversized length is logged as a security event and ends the connection.

real-venus and others added 3 commits June 26, 2026 00:41
Utility-Protocol#33)

Replaces delimiter-scanning (`read_until('\n')`) on the binary telemetry stream
-- which buffered the whole stream looking for a newline that never comes,
growing to GBs before OOM -- with bounded, length-prefixed framing:

- ingestion/buffer_pool: semaphore-gated recycling BufferPool (default 1024 x
  64KB = 64MB). acquire() awaits when all buffers are in flight (backpressure
  instead of unbounded allocation); released buffers are recycled, keeping the
  steady-state allocation rate ~0 (tracked via allocation_count()).
- ingestion/frame_parser: read_frame() reads the u32 BE length prefix, validates
  length <= MAX_FRAME_SIZE before reading, then read_exact()s exactly `length`
  bytes into a pooled buffer; CBOR is decoded zero-copy straight from the pooled
  slice (ciborium::de::from_reader, no per-frame Vec).
- ingestion/stream_handler: bounded frame loop; an oversized length is logged as
  a security event and ends the connection.
- benches/stream_throughput: criterion comparison of pooled vs per-frame-alloc
  reads over 10k frames.

Adds ciborium (pure Rust CBOR; no protoc/native toolchain) -- bytes/serde
already present. Self-contained (the issue's stream_handler.rs etc. did not
exist). Tests cover pool recycling/backpressure, frame read+decode, oversized
rejection before read, held-frame backpressure, and full-stream dispatch.
@elizabetheonoja-art

Copy link
Copy Markdown
Contributor

@real-venus CI failed

@real-venus

Copy link
Copy Markdown
Contributor Author

@real-venus CI failed

Now I am working on it.
@elizabetheonoja-art

@real-venus

Copy link
Copy Markdown
Contributor Author

@elizabetheonoja-art
fixed.

@elizabetheonoja-art elizabetheonoja-art merged commit 52f7fc6 into Utility-Protocol:main Jun 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telemetry Stream Ingestion Memory Backpressure with Zero-Copy Binary Frames

2 participants