Repository navigation
Read every input grain; count skipped grains - #8
Merged
Merged
Conversation
…pped grains mxlFlowReaderGetGrain answers MXL_ERR_OUT_OF_RANGE_TOO_EARLY (never MXL_ERR_TIMEOUT) when its wait runs out. The reader treated that as an answer that comes back at once and paused 10 ms. The wait is cut at the next update tick, so every tick paused; the update after the pause often ended after the next grain had come, and the reader jumped to the head over one grain without counting it. - No pause after MXL_ERR_OUT_OF_RANGE_TOO_EARLY. - New metric input_grains_skipped_total: grains the reader jumps over when it is behind. accumulate_dropped_total counts such a jump once. - Integration check: 1080p50 RGB parade at 25 Hz reads about 200 grains in 4 s (175 before), and read plus skipped is about 200. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ybuzgBaGxuB5UiaE8dRa4
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.
Problem
At 1080p50 with 25 Hz updates,
input_grains_totalgrew at about 47.9/s while the source wrote 50/s. No resyncs were counted, and no other metric showed the missing grains.Cause
src/mxlio/io.cpp, the input reader loop:mxlFlowReaderGetGrainwith a timeout answersMXL_ERR_OUT_OF_RANGE_TOO_EARLYwhen the wait runs out. It never answersMXL_ERR_TIMEOUT(MXL 218ddaa,PosixDiscreteFlowReader::getGrainImplwith a deadline). The reader thoughtTOO_EARLYcomes back at once, so it paused withwait(5). That pause really sleeps 10 ms, becausewaitsleeps in 10 ms steps.timeout = tick - now). So every 25 Hz tick ran into this pause. Then came the update (analyse and render, about 10 ms). Together that often took longer than one frame (20 ms). By then the head was 2 or more grains past the cursor, and the reader jumped to the head (want = headwhencursor + 1 < head). The jumped-over grain was not counted anywhere.Jumping to the head is on purpose: in
latestmode an update only needs the newest grain. The pause was the bug. Without it, the reader keeps up unless an update takes longer than a frame.Change
MXL_ERR_OUT_OF_RANGE_TOO_EARLY. It is a wait that ran out, like a timeout, so the loop does not spin. Other unexpected answers still pause.mxl_scopes_input_grains_skipped_totalfor grains the reader jumps over when it is behind. It is counted once, when the grain after the gap is read.accumulate_dropped_totalnow counts at the same place. Before, a wait that ran out with the cursor still behind could count the same gap again.Tests
tests/integration/scope.shhas a new check: a 1080p50scenewriter, RGB parade at 25 Hz, 4 s. It wants at least 180 grains read, and read plus skipped between 194 and 206.Note: the new integration check needs one update to take less than a frame on the CI runner (about 10 ms here for the RGB parade). A much slower runner would show skipped grains and fail the 180 bound.
🤖 Generated with Claude Code
https://claude.ai/code/session_017ybuzgBaGxuB5UiaE8dRa4