Skip to content

feat(uring): report per-worker io_uring counters at /metrics - #3408

Merged
kixelated merged 5 commits into
devfrom
quest/m1/uring-metrics
Sep 5, 2026
Merged

feat(uring): report per-worker io_uring counters at /metrics#3408
kixelated merged 5 commits into
devfrom
quest/m1/uring-metrics

Conversation

@kixelated

@kixelated kixelated commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add per-worker io_uring counters for buffer-pool health, batching, ring traffic, parking, wakes, and timer churn. moq-relay exposes them at /metrics as moq_relay_uring_*{worker="N"}.
  • Create every counter set during uring::Workers::bind, before worker threads start, so a worker that has not started or has died remains visible as a zero or stalled series instead of disappearing.
  • Document rx_enobufs as receive-side backpressure, not confirmed packet loss. Buffer selection fails before recv, so actual drops must be read from the socket's RcvbufErrors counter.
  • Keep the metrics API in its role namespace as moq_uring::metrics::{Metrics, Snapshot}. Cloning a worker Config creates fresh metrics so cloned configs cannot accidentally fold several workers into one series.
  • Count transmit stalls when the staging pool enters a drained episode, not on every poll while the same wait remains pending.
  • Fix the inherited moq-bench failed-group regression test. Its live subscription could skip groups because the test published the next cached group before the subscriber advanced. The test now synchronizes at each consumed frame or group instead of relying on a fixed number of scheduler yields.
  • Complete and remove quest/m1/uring-metrics.md and update the related quest links.

Prometheus is the only new output. These counters describe the process, not traffic crossing it, so nothing changes on the moq-stats wire.

Public API changes

rs/moq-uring 0.0.1, all additive relative to the base branch:

  • New public metrics module.
  • New metrics::Metrics (Clone, Default, Debug) with snapshot().
  • New metrics::Snapshot (#[non_exhaustive], Copy, Default, PartialEq) with 15 cumulative counters and timers_active().
  • New Config::metrics field. Config::clone() gives the cloned worker a fresh counter set.
  • New Handle::metrics() -> metrics::Metrics.

rs/moq-relay:

  • New Internal::with_uring(impl IntoIterator<Item = moq_uring::metrics::Metrics>).
  • New uring::Workers::metrics() -> Vec<moq_uring::metrics::Metrics>.

No wire behavior or encoding changes.

Test plan

  • just fix origin/dev
  • just check origin/dev
  • just test default origin/dev before the final transmit-stall delta: 389 passed, 1 skipped
  • Final metrics_record_pool_backpressure regression test, including repeated polls and a second stall episode
  • Targeted drain_survives_a_failed_group reproduction before and after the synchronization fix
  • New cloned_config_has_fresh_metrics regression test
  • Earlier feature-path verification: cargo clippy -p moq-relay --features io-uring --all-targets and cargo check -p moq-relay --all-targets
  • Live two-worker relay exercise under moq-bench; every counter moved and all worker series existed at zero before traffic

Not run: the io-uring-quinn / io-uring-quiche alternatives and the nightly all-features pass. This change does not touch backend-specific code.

Cross-package sync

  • Updated doc/bin/relay/http.md with each io_uring series, useful ratios, and alerting guidance. Updated doc/bin/relay/config.md to point to it.
  • Updated the moq-uring README, crate docs, and the crate map in rs/CLAUDE.md.
  • No moq-ffi, wire-format, CLI-surface, stats-wire, or C ABI changes. No draft or smoke-full update is required.

Completes quest/m1/uring-metrics.md, which lists no issues under Closes.

(written by GPT-5.6 Sol)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T04:22:52.870978Z 72d1aa2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ece18a22ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rs/moq-uring/src/metrics.rs
kixelated and others added 2 commits September 4, 2026 19:09
Claim UUID: a57652a8-a304-41a9-ac9e-b3d212f2f883
The relay's ops listener already carried traffic counters and accept
health, but nothing anywhere reported the io_uring runtime's own health.
Its failure modes are quiet ones: a receive pool running dry drops
datagrams with no error, and collapsed GRO/GSO batching only costs
syscalls.

moq-uring gains a Metrics handle over relaxed atomics the worker writes
on its own thread and anyone else snapshots: buffer-pool health, batch
effectiveness, ring traffic, and scheduling. moq-relay renders them as
moq_relay_uring_*{worker="N"}, hand-formatted beside the existing
counters.

Counter sets are created at bind, before the worker threads exist, so
every worker has a series from the first scrape. A series that only
appears once a worker has done something reads as a healthy node, and a
rate() over a missing series is empty rather than zero.

Prometheus only: these describe the process, not the traffic crossing
it, so nothing goes on the moq-stats wire.

Completes and deletes quest/m1/uring-metrics.md.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLtoPv9B3779kGxLFTUGHR
@kixelated
kixelated force-pushed the quest/m1/uring-metrics branch from ece18a2 to 14fdc77 Compare September 5, 2026 02:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14fdc7714c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rs/moq-uring/src/udp.rs Outdated
@kixelated

Copy link
Copy Markdown
Collaborator Author

Rebased onto dev (was 30 behind, conflicting).

One conflict, in quest/m1/perf/README.md. dev replaced /quest/m2/quic/uring-raw.md with /quest/m2/quic/noq-parity.md after this branch was cut, so the resolution takes dev's link targets and wording for that half, and this branch's half for the other: worker metrics is no longer described as a pending soft dependency ("use bench CPU/RSS until it lands"), because this PR is what lands it. The ## Related entry pointing at the now-deleted quest file is dropped; the noq parity gate entry stays.

Verified after rebase: quest check passes (246 documents ok), and just rs check-changed over the changed moq-uring/moq-relay files exits 0.

(written by claude-opus-5[1m])

…orker

An io_uring receive that ends in ENOBUFS never ran: buffer selection failed
before the recv, so the datagram is still queued on the socket. Calling every
increment a drop turns `rx_enobufs` into a false packet-loss diagnosis in the
documented alert. Describe it as receive-side backpressure that becomes loss
only once the socket buffer fills, and point at the socket's own counters for
actual drops.

`UringWorker` was `pub` for no reason. It only names the field type of two
private structs; a private alias resolves the same way in `with_uring`'s
signature, without publishing an uninhabited type from moq-relay's lib.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ae36b7c95

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rs/moq-uring/src/worker.rs
Comment thread rs/moq-uring/src/lib.rs Outdated
Co-Authored-By: GPT-5.6 Sol <noreply@openai.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

(written by GPT-5.6 Sol)

@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

(written by GPT-5.6 Sol)

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@kixelated I will review the changes in #3408.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d3cbc98e-f3f4-49b4-8cf6-bf4fd708d29b

📥 Commits

Reviewing files that changed from the base of the PR and between 419de62 and 72d1aa2.

📒 Files selected for processing (20)
  • doc/bin/relay/config.md
  • doc/bin/relay/http.md
  • quest/m1/README.md
  • quest/m1/perf/README.md
  • quest/m1/uring-metrics.md
  • quest/m1/uring-qlog.md
  • quest/m1/uring-tcp/README.md
  • rs/CLAUDE.md
  • rs/moq-bench/src/connection.rs
  • rs/moq-relay/src/internal.rs
  • rs/moq-relay/src/relay.rs
  • rs/moq-relay/src/uring.rs
  • rs/moq-uring/README.md
  • rs/moq-uring/src/lib.rs
  • rs/moq-uring/src/metrics.rs
  • rs/moq-uring/src/park.rs
  • rs/moq-uring/src/shared.rs
  • rs/moq-uring/src/timer.rs
  • rs/moq-uring/src/udp.rs
  • rs/moq-uring/src/worker.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kixelated

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

(written by GPT-5.6 Sol)

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@kixelated I will review the changes in #3408.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 7eb68a8459

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-Authored-By: GPT-5.6 Sol <noreply@openai.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the final commit, including the transmit-stall episode fix and regression test.

(written by GPT-5.6 Sol)

@kixelated

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

Please review the final commit.

(written by GPT-5.6 Sol)

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@kixelated I will review the final commit in #3408.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kixelated

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

The stated review-limit reset window has elapsed. Please review final commit 72d1aa2.

(written by GPT-5.6 Sol)

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Commit metadata =='
git show --no-ext-diff --no-renames --format=fuller --stat 72d1aa27a

echo '== Changed paths =='
git diff-tree --no-commit-id --name-status -r 72d1aa27a

echo '== Full commit diff =='
git show --no-ext-diff --no-renames --format= --find-renames=0 72d1aa27a

echo '== Rust source map =='
fd -e rs . | while IFS= read -r file; do
  ast-grep outline "$file" --items all --type function,struct,enum,impl 2>/dev/null || true
done

echo '== Targeted metric and pool references =='
rg -n -C 5 --glob '*.rs' \
  '(metrics_record_pool_backpressure|pool_backpressure|backpressure|tx_stall|transmit.*stall|staging.*pool|drained)' \
  rs

Length of output: 139719


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== udp.rs outline =='
ast-grep outline rs/moq-uring/src/udp.rs --items all

echo '== udp.rs relevant implementation =='
sed -n '260,430p' rs/moq-uring/src/udp.rs
sed -n '500,680p' rs/moq-uring/src/udp.rs
sed -n '680,820p' rs/moq-uring/src/udp.rs

echo '== worker regression test and helpers =='
sed -n '1020,1180p' rs/moq-uring/src/worker.rs

echo '== Tx free-list mutation sites =='
rg -n -C 4 --glob 'udp.rs' \
  '(tx\.free\.(push|pop)|free:\s*\(|stalled\s*=|release_tx\s*\(|complete_tx\s*\()' \
  rs/moq-uring/src/udp.rs

echo '== poll_acquire call contexts in moq-uring =='
rg -n -C 6 --glob '*.rs' '\.poll_acquire\s*\(' rs/moq-uring

Length of output: 43091


@kixelated Reviewed final commit 72d1aa27a.

I found no correctness issues in the transmit-stall episode fix or its regression test.

The stalled flag resets on each path that returns a transmit slot to the free list. The test verifies both repeated pending polls and a second drained-pool episode. I inspected the source only. I could not run the test suite in this environment.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 72d1aa27af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kixelated
kixelated merged commit ac8806f into dev Sep 5, 2026
2 checks passed
@kixelated
kixelated deleted the quest/m1/uring-metrics branch September 5, 2026 04:23
kixelated added a commit that referenced this pull request Sep 5, 2026
Adopts main's reorganized documentation site (#3426) and reconciles it with
dev's API and CLI surface: moq-native -> moq-tokio, `--client-connect` ->
`--connect`, `--latency-max` -> `--max-age`, `[server]`/`[client]` ->
`[listen]`/`[connect]`, origin id -> Hop ID, the context-taking Go calls, and
the origin-based JS and FFI publish APIs. Folds dev-only functionality into
the new pages rather than the deleted ones: hang text and data tracks, the LAN
cluster mesh, the `[runtime]` workers and io_uring counters, the wall-clock
cache sweep, routes and max age on the moq-lite page, and the broadcast-level
timeline the HLS gateway reads.

Repoints the quest links main added at documents dev had already retired:
uring-metrics (#3408), 2985 (#3422), and perf/session-micro (#3306).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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