Skip to content

fix(telemetry): measure software throughput over the seconds bytes arrived in (#306 follow-up) - #328

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/306-observed-transfer-rate
Aug 7, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/306-observed-transfer-rate

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Refs #306. Found while verifying the retest on that issue, not reported.

What the retest surfaced

The reporter's Network section only read sensibly on a struggling session, and their healthy run showed blanks they attributed to "nothing to measure". Reproducing that here says the healthy case was worse than a blank.

networkThroughputMbps on the software path was instantBitrateMbps: demuxer bytes over a 10 s wall-clock window. The reader fetches a large range and then parks on backpressure until low water, so on a fast link most ticks of that window carry no bytes at all.

Measured with aetherctl play against a 42 MB / 2.8 Mbps VP9 source over a local range-serving origin, before the change:

t=01 rx=16.4MB ahead=16.0MB
t=02 net=0.00Mbps rx=16.4MB ahead=15.5MB cushion=0.44s
...
t=23 net=0.00Mbps rx=16.4MB ahead=8.5MB  cushion=0.42s
t=25 net=6.92Mbps rx=24.6MB ahead=16.0MB      <- the next refill

23 consecutive ticks of a confident 0.00 Mbps on a session playing perfectly, while the runway drained from 16.0 to 8.3 MB. That is the same false-with-confidence zero #306 was filed about, one field over. The reporter had already been bitten by it: they now guard on > 0 rather than on non-nil, because their overlay renders any non-nil number it is handed.

The change

Divide by the seconds that carried bytes, not by every second of the window, and publish nil rather than zero when nothing arrived in the window at all.

That is the quantity the native path already reports: observedBitrate in the access log is the rate observed during a download event, and the sampler already drops it when it is not positive. So the field means the same thing on both backends again, which was the point of having it.

Publishing the gap rather than a zero keeps the choice on the host side, the same reasoning as shipping the runway in bytes: a host that wants a held reading keeps the last non-nil value, while a host handed a zero cannot tell a parked reader from a dead link.

After, same source and origin:

t=02..t=24  (no net= field; nothing arrived, so there is no rate)
t=25 net=68.16Mbps rx=24.6MB ahead=16.1MB     <- the refill, at loopback speed

The arm that must not move

The throttled run is the one the section was already legible on. With a 2 Mbps paced origin (30 ms latency) every tick carries bytes, so activeCount == count and both formulas agree:

t=02 net=2.10Mbps rx=0.6MB ahead=0.0MB cushion=0.00s
t=15 net=2.10Mbps rx=3.8MB ahead=0.0MB cushion=0.00s
t=30 net=2.10Mbps rx=7.5MB ahead=0.0MB cushion=0.00s

A 2.8 Mbps stream over a 2 Mbps link: steady link rate, ahead=0, cushion=0. Unchanged, and the starvation signature stays readable.

instantBitrateMbps is deliberately left alone. It is bytes per wall second on both paths, which is what makes it the stream rate rather than the link rate, and hosts calibrate against it today.

Also corrects the readerWindowAheadBytes doc comment, which told hosts to divide the runway by the throughput. That answers how long the runway took to fetch, not how long it will last at playback rate; the divisor is averageBitrateMbps. The reporter had already worked that out and quietly done it the right way.

Tests

Four in Issue306SoftwareTelemetryTests, over the measured shape: the burst-then-park window reports its delivered rate rather than a wall-clock mean; a steadily paced link reads identically either way; an idle window and a single sample both publish nil; and RollingWindow.activeCount separates the slots that carried bytes from the slots that exist.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE

…rived in (#306 follow-up)

networkThroughputMbps was a wall-clock mean over the 10 s byte window. The
playback reader fetches a large range and then parks on backpressure until low
water, so on a fast link most ticks of that window carry nothing: over a local
origin a healthy 2.8 Mbps VP9 session pulled 16.4 MB in one tick and then
exactly zero for the next 23, while its runway drained 16.0 -> 8.3 MB. The field
published a confident 0.00 Mbps through all of it, which is the same
false-with-confidence zero the issue was filed about, one field over.

It now divides by the seconds that carried bytes, which is the quantity the
native path already reports through observedBitrate, and it is nil rather than
zero when nothing arrived in the window at all. Publishing the gap keeps the
choice on the host side: a host that wants a held reading keeps the last non-nil
value, while a host handed a zero cannot tell a parked reader from a dead link.

The struggling arm is unchanged, which is the arm the section was already
legible on: with a 2 Mbps paced origin every tick carries bytes, so both formulas
agree and the session reads a steady 2.10 Mbps with ahead=0.

Also corrects the readerWindowAheadBytes doc, which told hosts to divide the
runway by the throughput. That yields how long the runway took to fetch, not how
long it lasts at playback rate; the divisor is averageBitrateMbps, which is what
the reporter had already worked out for themselves.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
@superuser404notfound
superuser404notfound merged commit adad8d1 into main Aug 7, 2026
5 of 6 checks passed
@superuser404notfound
superuser404notfound deleted the fix/306-observed-transfer-rate branch August 10, 2026 12:22
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