Skip to content

Add a latency benchmark and a proposal for a feature header - #11

Open
rednayan wants to merge 2 commits into
mainfrom
bench/latency
Open

rednayan wants to merge 2 commits into
mainfrom
bench/latency

Conversation

@rednayan

Copy link
Copy Markdown
Owner

Summary

Two additions. No library code changes.

  1. A latency benchmark (conformance/oracle/latency.c, latency.py, docs/latency.md). One C program for the C ABI runs as an outlet or as an inlet, and links to liblsl or to labstream. It stamps each sample with its own CLOCK_MONOTONIC at the push, so no row depends on a library clock. Each row names the library that the loader picked. --control adds a known delay of 1000 us, and the table must show it (966 us on the run below).
  2. A proposal for a feature header (docs/extensions.md, conformance/oracle/headerprobe.py). A labstream inlet offers Labstream-Features, and a labstream outlet answers it. liblsl ignores an unknown header on both sides (src/tcp_server.cpp:605-633, src/data_receiver.cpp:215-253). The page gives the syntax, the rules, where the framing can change, sketches for seq and shm, the rejected alternatives, and the conformance plan. Nothing is implemented.

First results (loopback, median of 3 runs of 10 s)

4000 Hz x 64 ch, chunks of 32 p50 us CPU outlet / inlet %
liblsl 318 3.3 / 1.7
main 382 9.3 / 10.8
fix/network-robustness (#9) 343 3.1 / 2.2
perf/quick-wins (#10) 328 3.2 / 2.2

With a push of one sample, all builds give a median of 70-100 us, like liblsl. No run lost a sample. The full table is in docs/latency.md.

Header probe

oracle/headerprobe.py sends one feed request with the header and one without to a real outlet. The answer headers and the test pattern are the same for liblsl, main and perf/quick-wins. A copy that sends a known header (Native-Byte-Order: 4321) shows a difference, so the probe can fail.

Not done

🤖 Generated with Claude Code

oracle/latency.c is one C program for the C ABI. It runs as an outlet or
as an inlet, and reads its own CLOCK_MONOTONIC. oracle/latency.py links
it to each library, runs each pair more than once, and makes a table.
Each row names the library that the loader picked. With --control, a
known delay of 1000 us must show in the table.

docs/latency.md gives the method and the first results for liblsl,
main, fix/network-robustness and perf/quick-wins. At 4000 Hz x 64
channels in chunks of 32, main uses 9 to 11 % CPU on each side. The
fix branch uses 2 to 3 %, near liblsl.
docs/extensions.md proposes the request header Labstream-Features. A
labstream outlet answers it, and liblsl ignores it on both sides. The
page gives the syntax, the rules, the byte where a feature can change
the framing, the first features (seq and shm), the rejected
alternatives, and the conformance plan. Nothing is implemented.

oracle/headerprobe.py sends a feed request with and without the header
to a real outlet. The answer headers and the test pattern must be the
same. It passes for liblsl and for labstream main. A probe with a known
header (Native-Byte-Order) shows a difference, so the probe can fail.
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.

1 participant