Skip to content

Ariadne conference: idle clients stop paying for their own traffic meters - #995

Merged
transfix merged 2 commits into
masterfrom
perf/conference-quiet-meters
Nov 3, 2026
Merged

transfix merged 2 commits into
masterfrom
perf/conference-quiet-meters

Conversation

@transfix

@transfix transfix commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Why

One idle conference client (camera and mic off, nothing moving) sent ~5 kb/s and received ~13 kb/s
through the relay. Nearly all of it was the traffic meters:

  • Every second each end rewrote net.{rtt_ms,in_kbps,out_kbps}, net.relay.* and server.net.*.
  • Each write was a touch plus a value: two ~130-byte state messages for one number.
  • The readings never repeat exactly, partly because those writes are what they measure.
  • The WebSocket re-broadcast then sent each changed leaf once more.

What changes

  • Meters (room_net):
    • A reading is published only when it moves off the one in the tree by a tenth of it, or by
      2 kb/s or 5 ms if that is more, or when it changes between measured and not.
    • It is written as two significant figures, never finer than a tenth (1200, 48, 0.4).
    • Each change journals one mutation (set_changed_once). server.net.links is written when it
      changes.
    • This covers the client's own meters (arigl), the relay's per-client meters and the relay's
      totals.
  • 5 s windows (net_publish_period_s):
    • The published rates are measured over 5 s.
    • arigl keeps a second rate meter for the room's copy. Its own row (self.ping/down/up) still
      updates every second.
    • arisrv publishes, and logs per link, every 5 s.
    • Why: with 1 s windows, a meter's own write and its re-broadcast were a few kilobits in one
      window. That pushed the next reading past the band and back, so the relay's out_kbps still
      wrote 0.7/s.
  • Reconnect: write_participant_net takes force. arigl sets it during its post-reconnect
    rejoin window, so a relay that lost the client's readings gets them back even when a steady
    reading would never move.
  • Energy: the relay stops re-stamping the reserve every 5 s once it matches the published value
    (full, at rest). The client's prediction refills to the same value, and it was corrected on the way
    there. write_avatar_reserve journals one mutation per changed leaf instead of touch + value on
    both.
  • Bench: arisrv_aoi_bench follows the relay's new meter cadence.

The Users window shows whole kb/s and ms, so it stays within a tenth of the measured value. A
reading can now be up to 5 s old.

Measured

Setup:

up down
before 5.1 kb/s (5.5 frames/s) 12.8 kb/s (12.3 frames/s)
after 0.09 kb/s (1.0 frames/s) 1.4–1.8 kb/s (3.2–3.7 frames/s)

What's left:

  • Up is the Ping/Pong pair.
  • Down is mostly pose.server_tick (1.0–1.3 kb/s), plus pings and the pose stream's heartbeat. The
    meters are under 0.1 kb/s.
  • The relay's own per-link meter agrees: 4.5–6.9 kb/s in and 13–19 out before, 0.1 in and 1.0–1.7
    out after.

Before, the down traffic broke down as:

  • relay per-client meters: 4.6 kb/s
  • server totals: 3.1 kb/s
  • WebSocket re-broadcasts re-carrying them: 3.3 kb/s
  • pose.server_tick: 0.8 kb/s
  • energy.*: 0.6 kb/s
  • pings and pose-stream heartbeats: ~0.4 kb/s

Not changed: the tree's pose.server_tick heartbeat

The heartbeat is what remains of an idle client's downlink. Stretching it to 5 s (the pose stream
already carries a 1 s heartbeat) was tried and backed out:

  • A client takes a still peer's tree tick, its last heartbeat, as a clock reading after a fresher
    stream sample. It seeks back, then forward again.
  • HolonTest.RealignCounterCountsSeeks pins this today: "a peer whose tick a heartbeat left old ...
    seeks the clock back".
  • At 1 s this already happens: a fresh join next to a still peer counted 2, 2 and 5 re-aligns. At
    5 s it counted 4 or more.
  • If the client stopped taking a sample older than one already applied as a clock reading (except
    far older, a restarted relay, as client_pump's 10 s leftover rule), the heartbeat could be
    stretched. That is a holon clock change for its own PR.

Tests

  • room_intrinsics_test NetReadingsReplicateOnlyWhenTheyMove: the bands, the rounding, one
    mutation per change, measured/unmeasured transitions, the forced re-send, and the relay's per-link
    meters and totals.
  • holon_sync_test AFullReserveAtRestIsNotRestamped: a full reserve at rest writes nothing for
    10 s, a walk publishes again, and the writer journals one mutation per changed leaf.
  • room_intrinsics_test, holon_sync_test, room_avatar_test, room_aoi_test,
    room_aoi_relay_test and room_relay_integration_test pass on a Windows static Release build.
  • clang-format 18.1.8 is clean.

Deploy

This needs a relay deploy and a page deploy to take effect in production.

CI note: this branch also carries #1003

The first run's only red check was ari_chat_component in package-linux / libcvc-debug-grpc. That
is a timing flake unrelated to this change: ari test gave each test program a running app's 0.1 s
budget, and that runner was about twice as slow as usual. #1003 fixes it. Its commit (84c3b2f) is
cherry-picked on top here so this PR's CI includes the fix. If #1003 merges first, a rebase onto
master drops the duplicate.

…ters

An idle client (camera and mic off, nothing moving) sent ~5 kb/s and received
~13 kb/s through the relay, nearly all of it the traffic meters. Every second
each end rewrote net.{rtt_ms,in_kbps,out_kbps}, net.relay.* and server.net.*
with a touch and a value (two ~130-byte state messages per number). The
readings never repeat exactly, partly because those writes are what they
measure, and the WebSocket re-broadcast then sent each change once more.

- room_net: a meter reading is published only when it moves off the one in
  the tree by a tenth of it, or by 2 kb/s or 5 ms if that is more (or between
  measured and not). It is written as two significant figures, never finer
  than a tenth, and each change journals one mutation (set_changed_once).
  server.net.links is written when it changes.
- The published rates are measured over net_publish_period_s (5 s): arigl
  keeps a second rate meter for the room's copy (its own row stays per
  second), and arisrv publishes and logs every 5 s. Over 1 s windows a
  meter's own write and its re-broadcast pushed the next reading past the
  band and back.
- write_participant_net takes FORCE. arigl sets it during its post-reconnect
  rejoin window, so a relay that lost the client's readings gets them again
  even though a steady reading would never move.
- The relay's energy reserve stops re-stamping every 5 s once it matches the
  published value (full, at rest); the client's prediction refills to the
  same value. write_avatar_reserve journals one mutation per changed leaf.
- arisrv_aoi_bench follows the relay's new meter cadence.

Tests: room_intrinsics_test NetReadingsReplicateOnlyWhenTheyMove;
holon_sync_test AFullReserveAtRestIsNotRestamped.
…ng app's 0.1 s

ari_chat_component failed every ctest attempt on a Debug CI runner with
"did not complete: time_limit_exceeded" on different subtests each time,
though it passes in about a second on other Debug runs and in 0.2 s locally.
ari test runs each test program as an action, and an action gets
ariadne.limits.action_max_time, 0.1 s of (mostly CPU) time. The chat
component's tests take a few thousand steps each: a few milliseconds in a
Release build, close to the 0.1 s in a Debug one, and past it on a runner that
ran the whole suite about twice as slowly as usual. The same subtests fail
locally once the budget is cut to a millisecond.

A test checks what a document does, not how fast. Under ari test a program's
time backstop is now the run's own --timeout (30 s by default), while the step
cap (action_max_steps) still stops a runaway. --action-time S sets it: 0.1
holds a document to what a running app allows, and 0 lifts it.

Tests: AriTest.AProgramMayRunAsLongAsTheTimeout (the default and 0 pass, a
millionth of a second kills the same program, a bad value is refused) and
AriadneHostCli.ActionTimeIsSecondsFromZero.
@transfix
transfix merged commit 942f81f into master Nov 3, 2026
25 of 28 checks passed
@transfix
transfix deleted the perf/conference-quiet-meters branch November 3, 2026 19:05
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