Skip to content

fix(measure): report a phone page's real wire size, not its plain JSON - #876

Merged
huichen merged 1 commit into
mainfrom
measure/page-wire-bytes
Sep 26, 2026
Merged

huichen merged 1 commit into
mainfrom
measure/page-wire-bytes

Conversation

@huichen

@huichen huichen commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

The history measurement called plain JSON plus crypto overhead the reply's "wire bytes". The client declares reply_gzip_v1, so a reply at or above 32 KiB leaves the desktop compressed (Compression::fast()) — which means the reported number overstated what a phone is billed, by up to 12× on a real page: 1.49 MB of "untrimmed wire" for a reply that actually goes out at 50 KB.

What changed

The measurement now runs the reply body the command loop builds through the shipping encoder (encode_reply_payload_with_gzip) and reports the compressed size, alongside the trim measured with and without the budget. The plain figures stay, because the budget comparisons are about content rather than bytes.

The numbers this corrects

Measured on the ten heaviest sessions — the page a phone receives is 14.7–64.6 KB gzipped (median ≈ 32 KB), from 51–354 KB of trimmed JSON.

requested page trim, same entries (plain) trim (gzip) reply a phone receives
236 entries 391,543 → 104,417 B (−73.3%) 149,107 → 32,446 B (−78.2%) 32,446 B
154 entries 388,069 → 65,859 B (−83.0%) 164,421 → 19,488 B (−88.1%) 19,488 B
1,094 entries 1,027,973 → 353,228 B (−65.6%) 240,513 → 64,550 B (−73.2%) 64,550 B

The trim's own share rises under compression (73.3% → 78.2%, 83.0% → 88.1%, 65.6% → 73.2%): what it removes — tool output, reasoning text, commands, file bodies — is the part that compresses worst, while the page that remains compresses to 18–31% of its plain size.

A second defect found while measuring

The trim's gzip share is now reported as unavailable when the untrimmed page exceeds the decoded-reply limit. The encoder then answers with an error body rather than the page, and reading a size off that produced a nonsense −62,000% "saving" on one real session (a 1.49 MB untrimmed page). That shape is reachable only with the budget disabled — no client asks for it; it exists to value the trim — so it is reported as n/a rather than as a number.

Verification

Desktop backend 1325 passed / 0 failed; cargo fmt --check and cargo clippy --all-targets -D warnings clean; scripts/docs/check-docs.py (205 docs) clean. Every number above comes from the shipping encoder on real pages.

No product behaviour changes — this is the instrument and the document about it.

The history measurement called plain JSON plus crypto overhead the reply's 'wire
bytes'. The client declares reply_gzip_v1, so a reply at or above 32 KiB leaves
the desktop compressed with Compression::fast() — which means the reported number
overstated what a phone is billed, by up to 12x on a real page (1.49 MB of
'untrimmed wire' for a reply that goes out at 50 KB).

The measurement now runs the reply body the command loop builds through the
shipping encoder (encode_reply_payload_with_gzip) and reports the compressed
size, alongside the trim measured with and without the budget. The plain figures
stay for the budget comparisons, which are about content rather than bytes.

Measured on the ten heaviest sessions: the page a phone receives is 14.7-64.6 KB
gzipped (median ~32 KB), from 51-354 KB of trimmed JSON. The trim's own share
rises under compression — 73.3% / 83.0% / 65.6% plain becomes 78.2% / 88.1% /
73.2% gzipped — because the removed content (tool output, reasoning, commands,
file bodies) compresses worst, while the remaining structure compresses to
18-31% of its plain size.

Also reports the trim's gzip share as unavailable when the untrimmed page exceeds
the decoded-reply limit: the encoder then answers with an error body rather than
the page, and reading a size off it produced a nonsense -62,000% 'saving' on one
real session (a 1.49 MB untrimmed page). That shape is reachable only with the
budget disabled, which no client asks for — it exists to value the trim.

Docs: CONNECTION.md's history table now leads with the byte a phone is billed and
records why the plain number is not it.
@huichen
huichen enabled auto-merge (squash) September 26, 2026 14:03
@huichen
huichen merged commit 945199e into main Sep 26, 2026
12 checks passed
@huichen
huichen deleted the measure/page-wire-bytes branch September 26, 2026 14:12
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