Repository navigation
Conversation
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.
docs/extensions.md now gives the seq/1 feature in full: one counter for the whole outlet, a 9-byte numbering record (tag 0xFE, little-endian number), the count rules on the inlet, and what the inlet reports. The configuration key labstream.Features turns a feature off. labstream-proto gets two pure modules. features reads, writes, offers, answers and agrees the Labstream-Features tokens. seq writes and reads the record, decides when the outlet writes one, and counts the lost samples. FeedParams::to_wire_with, FeedClient::start_with, FeedClient::features and Accepted::to_wire_with add the header to the handshake. With no tokens, each gives the same bytes as before.
An inlet offers seq/1 in the Labstream-Features header. A labstream outlet answers it, and liblsl ignores it on both sides. The outlet numbers each pushed sample with one counter. Each consumer queue keeps the number after its last sample, so the samples in it always have consecutive numbers. The writer puts a numbering record before the first sample of a connection, and before each sample after a gap. A blocking outlet does the same. The inlet reads the records and counts the numbers that never arrived. The count stays across a reconnect to the same outlet, and starts again for a new outlet. Inlet::samples_lost in labstream-net and Inlet::lost in labstream give it. The value is None when the connection does not use seq/1. The configuration key labstream.Features turns the feature off. Tests: a model test of the queue numbers, records cut at each byte in both byte orders, the records of the writer, and three live tests. In the live tests, the received, lost and dropped samples add up to the pushed samples, for a full outlet queue and for a lost connection.
docs/extensions.md now gives the status of each item of the conformance plan. Each item passes on this branch: the header probe on liblsl, main and seq outlets, the interop matrix with seq on and off, and the unit and live tests. oracle/headerprobe.py now accepts one Labstream-Features answer line with offered tokens only. Without that line, the answer headers must be the same, and the test pattern must be the same.
A run with seq last in each group showed a slower median at 512 Hz. With seq first, seq and quick gave the same numbers. At 4000 Hz x 64 channels, seq/1 does not change the latency or the CPU.
The outlet now writes the opening record at once, after the test pattern and before any sample, in both the queued and the blocking mode. A gap from a lost connection thus shows when the inlet connects again, also on a quiet stream such as a marker stream. Before, it showed only with the next sample. New live tests: a_gap_shows_at_once_on_a_quiet_stream and a_new_outlet_starts_a_new_count. Each fails without its fix (lost Some(0) instead of Some(20), and Some(1067) instead of Some(0)). oracle/headerprobe.py now also reads the first data byte. It must be a sample tag, or the record tag 0xFE when the answer holds seq/1. A test of the configuration default of labstream.Features is added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #10 (which holds #9), with #11 merged in. The base is
perf/quick-wins, so the diff shows #11 and the seq work. Merge order: #9, #10, #11, then this. After each merge, change the base of the next one.Summary
The first labstream-only feature:
seq/1, sequence numbers. Two labstream peers number their samples, and the inlet counts the samples that never arrived. liblsl ignores the feature on both sides. The spec is indocs/extensions.md.seq/1in the request headerLabstream-Features. A labstream outlet answers it. liblsl reads only the header keys that it knows (src/tcp_server.cpp:605-633,src/data_receiver.cpp:215-253).0xFE(not a sample tag,src/sample.h:19-20) and a little-endianu64. The outlet writes one record at the start of each connection, and one before each sample after a gap. A record does not count towardMax-Chunk-Length.labstream:Inlet::lost() -> Option<u64>.labstream-net:Inlet::samples_lost(),SampleQueue::with_first_number,SampleQueue::pop_many_numbered,Fanout::next_number,Config::features.labstream-proto: thefeaturesandseqmodules,FeedParams::to_wire_with,FeedClient::start_with,FeedClient::features,Accepted::to_wire_with.Nonemeans unknown (for example a liblsl outlet), not zero.[labstream] Features = {}in the configuration file. On by default.Tests
clippy -D warnings,doc -D warnings, 306 workspace tests.main, with seq on and withFeatures = {}:--zero-stamps,--desc,--postproc 7and selftest: 28/28;--chunk 16: 26/28, and--sync: 24/28 (liblsl itself refuses the failing string cells);main(the same code asv0.1.2belowcrates/) give no answer line and a sample tag first;seqanswersseq/1and starts the data with0xFE;docs/latency.mdalso notes that the order of the runs can move a result at 512 Hz.For review
Configgets a new public field.docs/versioning.mdcounts only a removal or a signature change as breaking, so this PR treats the field as new API.Not verified
🤖 Generated with Claude Code