Skip to content

test(remote): measure the phone's lane as the phone actually negotiates it - #865

Merged
huichen merged 2 commits into
mainfrom
test/measure-phone-page
Sep 26, 2026
Merged

huichen merged 2 commits into
mainfrom
test/measure-phone-page

Conversation

@huichen

@huichen huichen commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Three instrument faults, each of which had produced a wrong number. No product code changes.

1. The harness never installed the live-lane capability flags

They live in the per-pairing shared runtime, and coalesce_events() answers an unknown pairing with a fresh, disabled flag rather than an error. So declaring coalescing succeeded, the reply asserted success, and the flag was written to a throwaway Arc while the drain read another one. Every "coalesced" reading in this harness was the undeclared lane.

E2e::on_broker now installs the shared runtime the way the supervisor does before building the transport, and the measurement asserts both the flag and that merging actually happened — so it cannot pass unnoticed again.

That fix needed two more:

  • Flow control counted messages as events. One merged message stands for coalescedCount source events, so decrementing per message left the drain permanently "behind" and asked for a full merge window on nearly every event: a 3-minute measurement became hours. It now counts covered source events.
  • assert_lane assumed one message per event. A merged message keeps its group's newest envelope and idx and carries the whole group's text — which is exactly how the client reads it (start = idx - coalescedCount + 1). My first attempt asserted the group's first idx and failed on real data; the fixture test now covers the coalesced lane so the shape is pinned without a 5-minute run.

2. The history measurement was not measuring the phone's page

dump_entries fetched a whole session and let the bridge's 512 KiB budget reduce it. That answers "as many newest exchanges as fit in the budget", not the newest HISTORY_PAGE_USER_EXCHANGES — which is 3 (lowered from 10 in #607), and which my earlier report had as limit: 10. On a lean page that overstated by ~3×.

The scripted agent now pages like the real one (paginate_backward: newest N user exchanges ending at the cursor), and measure-lean-history.py --phone-page N measures the real page through the shipping trim and budget. A --session flag lets a run name the same sessions the other measurement uses.

3. The numbers follow

Three heaviest runs, real Noise+AEAD, as the phone actually negotiates it:

Lane Messages Wire bytes
undeclared 174,791 / 166,685 / 154,907 70,330,622 / 66,634,886 / 60,876,773
coalesced only 4,174 / 4,127 / 3,383 3,115,440 / 2,967,307 / 2,437,683
coalesced + lean 1,320 / 1,409 / 896 818,013 / 819,590 / 472,645

The trim's own contribution to a phone is −72% to −81%, not the ~−98% a raw-to-lean ratio suggests — that ratio credits the trim with merging it did not do. CONNECTION.md now states both steps separately, and its history figures are the phone's page rather than a whole session.

Checks

  • desktop remote:: 179 passed, remote_host:: 83 passed; cargo fmt --check + clippy --all-targets -D warnings clean
  • python3 scripts/docs/check-docs.py — 205 docs OK
  • The measurement runs end to end from this branch (--samples 3 --broker fake), needing only the live agent's db + socket.

…es it

Three instrument faults, each of which had produced a wrong number:

**The harness never installed the live-lane capability flags.** They live in the
per-pairing shared runtime, and `coalesce_events()` answers an unknown pairing
with a fresh, *disabled* flag rather than an error — so declaring coalescing
succeeded, asserted success, and wrote to a throwaway flag while the drain read
another. Every "coalesced" reading was the undeclared lane. `E2e::on_broker` now
does what the supervisor does before building the transport, and the measurement
asserts the flag and that merging actually happened.

That also needed the harness's flow control to stop counting messages as events:
one merged message stands for `coalescedCount` source events, so decrementing per
message left the drain permanently behind and asked for a full merge window
almost every event (a 3-minute measurement became hours). `assert_lane` learns
the same shape — a merged message keeps its group's *newest* envelope and `idx`
and carries the whole group's text, which is how the client reads it
(`start = idx - coalescedCount + 1`).

**The history measurement was not measuring the phone's page.** `dump_entries`
fetched a whole session and let the bridge's 512 KiB budget reduce it, which
answers "as many newest exchanges as fit", not the newest
`HISTORY_PAGE_USER_EXCHANGES` (3, since #607) the phone asks for — three-fold
high on a lean page. The scripted agent now pages like the real one
(`paginate_backward`), and `measure-lean-history.py --phone-page N` measures the
real page through the shipping trim and budget. Its `--session` flag lets a run
name the same sessions the other measurement uses.

**The numbers follow.** On the three heaviest runs, the phone's lane is
undeclared 70.3 / 66.6 / 60.9 MB → coalesced 3.12 / 2.97 / 2.44 MB → coalesced +
lean 0.82 / 0.82 / 0.47 MB. The trim's own contribution is **-72% to -81%**, not
the ~-98% a raw-to-lean ratio suggests: that credits the trim with merging it
did not do. `CONNECTION.md` now states both steps, and its history figures are
the phone's page rather than a whole session.
@huichen
huichen enabled auto-merge (squash) September 26, 2026 04:45
@huichen
huichen merged commit d4a0468 into main Sep 26, 2026
12 checks passed
@huichen
huichen deleted the test/measure-phone-page branch September 26, 2026 04:53
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