Skip to content

latency/histo binstream: fix FIFO sizing and fail visibly on error#4102

Open
grandixximo wants to merge 3 commits into
LinuxCNC:masterfrom
grandixximo:fix/issue-4101-sbins1000
Open

latency/histo binstream: fix FIFO sizing and fail visibly on error#4102
grandixximo wants to merge 3 commits into
LinuxCNC:masterfrom
grandixximo:fix/issue-4101-sbins1000

Conversation

@grandixximo
Copy link
Copy Markdown
Contributor

Fixes #4101

FIFO sizing

The hal_stream ring buffer keeps one slot permanently empty to tell full from empty apart, so its usable capacity is depth - 1. Both histogram stream components sized their FIFO to exactly one snapshot, so at the maximum bin count the last record overran and the reader waited forever for a depth that never arrived:

component FIFO depth one set usable broke at
latencybinstream 2*MAXBINNUMBER+1+2 = 2003 2003 2002 --sbins 1000
histobinstream MAXBINNUMBER+2 = 202 nbins+2 = 202 201 --nbins 200

This is why --sbins 999 worked but --sbins 1000 failed with:

servo: stream timeout (depth 2002 < 2003)
servo: stream-error set (FIFO too small for 2003 records)

Each component now allocates one extra slot so a complete set always fits.

Error handling

Following rodw's note that the tool should not open in a broken state: the stream read loop previously only printed to the console and returned, leaving the window open, blank and non-updating while spamming the console every cycle.

  • A hard stream-error (FIFO too small) is unrecoverable, so it now pops up a dialog and quits via a new fatal proc, matching the existing availablebins startup check.
  • A plain timeout may be transient, so it now raises a one-shot visible warning after it persists rather than only logging to the console.

Both latency-histogram and hal-histogram get the matching changes.

The FIFO held 2*MAXBINNUMBER+1+2 records, but the hal_stream ring buffer
reserves one slot, so usable capacity is depth-1. At 1000 bins the last
of the 2003 records overruns, the reader times out, and latency-histogram
fails with --sbins 1000. Add one slot so a full set fits.

Fixes LinuxCNC#4101
Same off-by-one as latencybinstream: the FIFO held MAXBINNUMBER+2
records, but the hal_stream ring buffer reserves one slot, so usable
capacity is depth-1. At the max 200 bins the last of the 202 records
overruns and hal-histogram times out with --nbins 200. Add one slot.
The stream read loop only printed to the console on error and returned,
so a hard FIFO sizing error left the window open and silently
non-updating while spamming the console every cycle (the symptom in
issue LinuxCNC#4101 before the FIFO fix).

Treat the two error kinds differently:
- stream-error (FIFO too small) is unrecoverable, so pop up a dialog and
  quit via a new fatal proc, matching the existing availablebins check.
- a plain timeout may be transient, so warn once with a popup after it
  persists rather than only logging to the console.
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.

latency-histogram errors where --sbins 1000

1 participant