Skip to content

P1.3 follow-up: reproducibly measure zero-copy stream parsing's allocation payoff (concurrent-parse benchmark) #64

Description

@joeldsouzax

Follow-up to #30 (zero-copy stream parsing). Everything here must be reproducible — a committed benchmark + a documented command + pasted numbers, not a belief.

Why

#30 traded ~25% parse CPU (CodSpeed: controller_idx_sigs_1sig −27.7%, multi_group_controller_witness −21.7%) for fewer heap allocations (~N → 1 per multi-group message). The allocation reduction is proven (tests/allocation.rs, mutation-verified). But the payoff is unproven: no benchmark yet shows fewer allocations translating into a throughput or latency win anywhere. Single-threaded benches show a net regression (correct-but-slower). So "was #30 worth it?" is currently a belief, not a measured result — which violates the reproducibility bar.

Goal

Make "does the zero-copy allocation reduction actually pay off?" a reproducible measurement.

The measurement (the one place it should win)

Add a committed, deterministic benchmark that parses many small streams concurrently across N threads, comparing:

  • branch (copy-once: 1 alloc/stream), vs
  • origin/main behavior (per-group copy: N allocs/stream).

Under multi-thread allocator contention, N-allocs-per-stream should hit the global allocator lock far more than 1-alloc-per-stream — this is the scenario where fewer allocations converts to throughput. Measure wall-clock throughput and allocation counts at increasing thread counts (1, 2, 4, 8…).

Acceptance criteria (reproducible)

  • A committed benchmark (criterion/CodSpeed-compatible) + a single documented command anyone can run.
  • Before/after numbers pasted (branch vs origin/main behavior) across thread counts.
  • A clear, re-runnable verdict:
    • Wins under concurrencyP1.3 · Zero-copy stream parsing #30 is vindicated as a concurrency/memory-pressure improvement; keep it, update the CHANGELOG with the measured win.
    • Shows nothingP1.3 · Zero-copy stream parsing #30's lasting value is the safeguards + bug fixes, not the zero-copy; open a decision to revert the sync-path zero-copy (keep codec + safeguards).
  • Consider also measuring no_std/constrained-allocator behavior if feasible.

Pointers

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance / zero-copy workresearchCard requires an up-front research pass (crates, patterns, papers, prior art) before implementation

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions