feat(moq-net,moq-cli): per-track stats + moq-cli --stats usage display#1671
Open
kixelated wants to merge 1 commit into
Open
feat(moq-net,moq-cli): per-track stats + moq-cli --stats usage display#1671kixelated wants to merge 1 commit into
moq-cli --stats usage display#1671kixelated wants to merge 1 commit into
Conversation
Make moq-net stats per-track and surface them as a live usage table in moq-cli. A broadcast total stays O(1) to read: the existing broadcast-level `Counters` rollup is kept in sync on every bump, so reading a total never iterates the per-track map. moq-net: - Add `TrackCounters` and per-(side,tier) track maps on `BroadcastEntry`. The track guards bump both the broadcast rollup and the track's own atomics. - Add `Stats::snapshot() -> StatsSnapshot` (+ public `BroadcastSnapshot` / `SideSnapshot` / `TrackCounts` / `SessionCounts`) so an in-process consumer reads counters directly instead of subscribing to the `.stats` broadcast. - The published per-broadcast JSON gains an additive `tracks` object; the wire frame now reuses `SideSnapshot` instead of a separate struct. `Tier::idx` is public since the snapshot arrays are tier-indexed. - Dead tracks are GC'd in the snapshot task; their bytes remain in the rollup. moq-cli: - Add `--stats` / `--stats-interval` to publish/subscribe/serve/accept. Builds an enabled aggregator (throwaway origin), attaches the tier handle via `with_stats`, and repaints a per-track table on stderr each interval, with rates derived from successive snapshots. stdout stays clean for piped media. docs: document the `tracks` field in doc/bin/relay/config.md and the `--stats` flag in doc/bin/cli.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Adds a live usage display to
moq-cliand makes the moq-net stats per-track to back it. Run any transfer with--statsto see which tracks are being produced/consumed and a continuously rewritten upload/download table:The stats system was broadcast-scoped and only exposed via a published
.statsbroadcast. This makes it per-track and adds an in-process read API so a CLI can render it directly.Broadcast totals stay O(1) to read. The existing broadcast-level
Countersrollup is kept in sync on every bump, so reading a total is a single atomic load and never iterates the per-track map. The per-track maps are only walked when someone actually wants the per-track view (the snapshot task once per tick, or asnapshot()call).moq-net
TrackCounters+ per-(side, tier)track maps onBroadcastEntry. The track guards (PublisherTrack/SubscriberTrack) now bump both the broadcast rollup and the track's own atomics.Stats::snapshot() -> StatsSnapshot(plus publicBroadcastSnapshot/SideSnapshot/TrackCounts/SessionCounts) for in-process consumers. No broadcast subscription required.tracksobject; the wire frame now reusesSideSnapshotrather than a duplicate struct.Tier::idxis now public since the snapshot arrays are tier-indexed.moq-cli
--stats/--stats-intervalflags onpublish,subscribe,serve,accept.with_stats, and a render loop diffs successivesnapshot()s to compute rates and repaints a per-track table on stderr (stdout stays clean for piped media). A process is single-direction, so the table just shows the active broadcast/track totals.Docs
doc/bin/relay/config.md: document the newtracksfield in the stats JSON.doc/bin/cli.md: document--stats.Cross-package sync
The
moq-net wire/APIrow points atjs/net+doc/concept. There's no JS stats aggregator to mirror; the per-broadcast stats JSON is a relay-internal feature (consumed by dashboards), and its format change is additive and documented indoc/bin/relay. No peer wire-protocol change.Test plan
cargo fmt+clippyclean (via nix);moq-relay/moq-nativestill build.ffmpeg | moq-cli serve+moq-cli subscribe --statsover QUIC renders the per-track table with live rates.(Written by Claude)