Skip to content

Commit a532f6a

Browse files
authored
bench(streaming): mpsc vs crossbeam vs direct callback (refs #482) (#485)
Add `streaming_channels` criterion bench measuring the per-event cost of the producer/consumer hand-off the FFI streaming surface pays for every FPSS event delivered to a buffered consumer. Five variants: - `std_mpsc_unbounded` — current live shape (`std::sync::mpsc::channel()` + `recv_timeout(100ms)` poll). - `crossbeam_bounded_{256,1024,8192}` — lock-free SPSC candidate at three capacity points covering the proposed backpressure range. - `direct_callback` — no channel; producer invokes an `extern "C" fn` through a `Box<dyn Fn>` trampoline, modelling the C/C++ tier-1 path. Payload mirrors `ffi::streaming::FfiBufferedEvent` field-for-field: `#[repr(C)]` tagged event with `TdxContract` embedded in every data variant plus two heap-owned tails (`Option<CString>` + `Option<Vec<u8>>`). Sizes match the generated `fpss_event_structs.rs` byte-for-byte (Event = 448 B, BufferedEvent = 488 B on x86_64). `crossbeam-channel` is added to dev-dependencies only so the runtime dep graph is unchanged. The implementation switch ships in a follow-up PR after we read the numbers.
1 parent dc1ccc5 commit a532f6a

3 files changed

Lines changed: 468 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/thetadatadx/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ zeroize = { version = "1.8.2", features = ["derive"] }
118118

119119
[dev-dependencies]
120120
criterion = { version = "0.8.2", features = ["html_reports"] }
121+
# Bench-only: lock-free SPSC/MPSC channel candidate for replacing
122+
# `std::sync::mpsc` on the FFI streaming hot path (issue #482). Kept in
123+
# dev-dependencies so the runtime dep graph is unchanged until the
124+
# implementation switch ships in a follow-up PR after we read the
125+
# numbers from `benches/streaming_channels.rs`.
126+
crossbeam-channel = "0.5.15"
121127
# Test-only: load captured-response fixtures and their sidecar .meta.toml
122128
# files for the decoder-regression suite (`tests/test_decode_captures.rs`).
123129
# `toml` is already a build- and opt-dependency here; adding it to
@@ -154,6 +160,10 @@ harness = false
154160
name = "bench_fpss_event"
155161
harness = false
156162

163+
[[bench]]
164+
name = "streaming_channels"
165+
harness = false
166+
157167
[[bin]]
158168
name = "generate_sdk_surfaces"
159169
path = "src/bin/generate_sdk_surfaces.rs"

0 commit comments

Comments
 (0)