moq-net: a joining session costs ~34 ms of relay CPU, mostly announce discovery and driver polling

オープン
#10,327 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust

調査の方向性

Start by locating the named announce and session driver paths, including AnnouncePrefix, AnnounceRun, Discovery, OriginState::snapshot, and lite::session::Driver::poll_protocol; the issue provides no file paths or reproduction command. Profile joins with and without announcements, then trace why discovery and polling run before the first subscription settles. Done means announce discovery is independent of origin contents when unused, or deferred until requested, and the excess driver polling is explained.

索引モデルが issue の本文から書いたものです。

説明

Problem

A session joining a relay costs about 34 ms of host CPU, independent of how many sessions are already connected, and most of it is not the QUIC or TLS handshake. At 16.7 joins/s that is 0.57 of a 2-vCPU relay's cores, so the connection count at which the relay's CPU-based shed trips depends on the arrival rate more than on fan-out.

Measurement

  • Relay: moq-relay from moq 62c0ec81, frame-pointer release build, on a 2-vCPU dedicated AMD EPYC 7713 VM (kernel 6.18).
  • Load: moq-bench --fanout chat --fps 1 --frame-size 200 from two generators, each with one 1:N channel, ramping linearly at 8.3 connections/s each (16.7/s total).
  • Steady: 45 s of perf record -F 99 --call-graph fp -a at a constant 3,000 connections and no joins. Host 0.764 cores, relay process 0.648, idle host 0.038, so steady state costs 0.242 host cores per 1,000 connections at 1 msg/s.
  • Ramp: 140 s capture while the ramp went from 915 to 3,077 connections (mean about 2,000). Host 1.096 cores, process 0.984. The steady model gives 0.52 host cores at 2,000 connections, which leaves 0.575 host cores for 16.7 joins/s: about 34 ms per join. Slicing the ramp capture into 10 s bins puts that excess roughly constant from 900 to 3,100 connections.

Ramp minus steady (scaled to the ramp's mean connection count), relay-process cores, each sample assigned to the first category whose frames it contains:

Category (matching frames) Ramp Steady Excess
announce/origin discovery (AnnouncePrefix, AnnounceRun, Discovery, OriginState::snapshot, origin_impl::TableCursor::awaits, Prefixes::overlaps/covering, Snapshot drop) 0.146 0.004 0.141
session accept/setup (server::Handshake, start_lite, accept path) 0.018 0.003 0.015
subscribe request outside TrackRun (SubscribeServe, TrackInfoServe) 0.087 0.017 0.070
subscriber side (SubscriberDriver: UniAccept, end_datagrams) 0.100 0.032 0.068
TrackRun/GroupServe 0.228 0.183 0.045
QUIC driver, crypto, sendmsg 0.149 0.107 0.041
other: mostly lite::session::Driver::poll_protocol and session::Supervisor::poll 0.257 0.084 0.173

Path parsing shows up inside the announce category: CharSearcher::next_match and path::parts::Parts::next take 3.7% and 4.9% of all ramp samples. The viewers announce nothing and subscribe to one named broadcast, so each join is paying to build and drop an origin snapshot and to match prefixes it never uses.

Ask

  • Make a new session's announce discovery cost independent of what the origin holds when the client has not asked for announcements, or defer it until it does.
  • Find out why a newly started session's driver polls so much more than a steady one (the 0.17-core "other" row) before its first subscription settles.

Caveats: perf's sample counts on this VM read 1.4-1.6x the kernel's process ticks, so absolute cores above come from /proc ticks and the samples only provide shares. The steady model is linear from one point (3,000 connections).

(Written by Claude Opus 5.5 with medium)

主要言語
Rust
スター
1.6k
フォーク
251
平均マージ
10時間 10分
マージ済み PR(30日)
832

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

moq-dev/moq のほかの issue

moq-dev/moq の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。