Repository navigation
fix(measure): report a phone page's real wire size, not its plain JSON - #876
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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/arather than as a number.Verification
Desktop backend 1325 passed / 0 failed;
cargo fmt --checkandcargo clippy --all-targets -D warningsclean;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.