Parent
Architecture review (2026-06-21), "Latency tricks worth lifting wholesale". Lifted from Satellite's net/receiver.cpp:99-103. Independent of the deepening series.
What to build
In usbip-server's URB receive loop, the per-URB latency sample is currently posted to a shared atomic. The cross-thread CAS contention on a 1 kHz+ URB stream is measurable. Lift Satellite's per-thread high-water-mark pattern:
- Each worker thread keeps a
thread_local HighWaterMark { local_peak_ns: u64, last_flushed_at: Instant }
- On each URB, the worker compares its local
latency_ns to local_peak_ns using a relaxed load (no cross-thread CAS)
- Only when
latency_ns > local_peak_ns does the worker perform the cross-thread atomic CAS on the global high-water-mark
- The CAS frequency drops from "every URB" to "only when a new local peak is set" — empirically ~1% of packets in steady state
This is a small, self-contained optimization with measurable latency-tail improvement under load. It does not change wire protocol, error handling, or test surface beyond one new benchmark.
Acceptance criteria
Blocked by
None — can start immediately.
Parent
Architecture review (2026-06-21), "Latency tricks worth lifting wholesale". Lifted from Satellite's
net/receiver.cpp:99-103. Independent of the deepening series.What to build
In
usbip-server's URB receive loop, the per-URB latency sample is currently posted to a shared atomic. The cross-thread CAS contention on a 1 kHz+ URB stream is measurable. Lift Satellite's per-thread high-water-mark pattern:thread_local HighWaterMark { local_peak_ns: u64, last_flushed_at: Instant }latency_nstolocal_peak_nsusing a relaxed load (no cross-thread CAS)latency_ns > local_peak_nsdoes the worker perform the cross-thread atomic CAS on the global high-water-markThis is a small, self-contained optimization with measurable latency-tail improvement under load. It does not change wire protocol, error handling, or test surface beyond one new benchmark.
Acceptance criteria
HighWaterMarkis a new private struct inusbip-server/src/urb_loop.rs(or wherever the receive loop lives)benches/urb_high_water_mark.rsbenchmark compares the cross-thread CAS rate before and after (criterion-based, default sample size)cargo test --workspace --releasepasses;cargo clippy --workspace -- -D warningscleanLatencySampleshape emitted on/api/eventsis unchangedBlocked by
None — can start immediately.