Skip to content

fix(measure): read a phone page's trim and its byte budget apart - #875

Merged
huichen merged 1 commit into
mainfrom
fix/measure-page-truth
Sep 26, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/measure-page-truth

Conversation

@huichen

@huichen huichen commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Fixes two measurement defects that produced wrong numbers, one of which is in a documented claim.

1. The phone-page measurement compared incomparable pages

measure_phone_page built the undeclared and lean pages and asserted the lean one was never larger — then reported saved = 1 - lean/undeclared. That is false whenever the 512 KiB budget cuts one page and not the other, because the budget sheds whole oldest exchanges.

On a real session page:

entries wire
undeclared (budget applied) 77 130 KiB
lean (fits, delivered whole) 805 280 KiB

The undeclared client was cut to 77 of the 805 entries the phone asked for; the lean page fit and arrived whole. The lean page is larger there precisely because it still holds the exchanges the other had to drop — the outcome the trim exists for. The assertion called that a regression, and the report printed a negative "saved", as if the trim had cost bytes.

Two effects, now measured apart:

  • Trim, same entries (no budget) — the only like-for-like comparison, and where saved comes from.
  • Delivered — what each client actually receives, entries and bytes.

The asserted invariant is the one that actually holds: the lean page never delivers fewer entries than the undeclared one.

Measured on six real sessions: the trim is −73.0% to −83.0% of the requested page, and in three of the six the undeclared client's page is truncated while the lean one is whole (97 vs 825 entries, 279 vs 325, 276 vs 600).

Falsified: injecting an entry drop into the lean build makes it fail with the lean page must not deliver fewer entries than the undeclared one (236 vs 235).

2. measure-live-lane.py picked its binary alphabetically

target/debug/deps keeps every historical build of the test binary. The script took sorted(...)[0], not the newest by mtime — so it silently measured the trims of an older commit and printed plausible numbers. A run here reported 0.76 MB where the current lane is 0.19 MB (the state from four PRs earlier). The other measurement scripts already select by mtime; only this one did not.

Docs

CONNECTION.md's history-page table was built from the mixed comparison (it claimed 69.4% / 76.9% / 88.6% on a basis that measures nothing when the budgets differ). Replaced with the separated table plus the whole-session trim figures (−76.8% / −76.6% / −80.1%), and the note about why comparing raw bytes across the two clients is meaningless.

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. Both effects reproduced through the shipping trim and budget on real pages.

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

The phone-page measurement compared the two clients' delivered bytes directly
and asserted the lean page was never larger. That is false whenever the 512 KiB
budget cuts one page and not the other, because the budget sheds whole oldest
exchanges: on a real session page the undeclared client was cut to 77 of the 805
entries the phone asked for, while the lean page fit and was delivered whole —
280 KiB against 130 KiB. The lean page is larger there precisely because it still
holds the exchanges the other had to drop, which is the outcome the trim is for.
The assertion made that look like a regression and the report printed a negative
"saved" as if the trim had cost bytes.

Now the two effects are measured apart: the trim with and without the budget
(the only like-for-like comparison, and where `saved` comes from), and what each
client actually receives. The invariant asserted is the one that holds — the lean
page never delivers fewer entries than the undeclared one.

Measured on six real sessions, the trim is -73.0% to -83.0% of the requested page,
and in three of them the undeclared client's page is truncated while the lean one
is whole (97 vs 825 entries, 279 vs 325, 276 vs 600).

Also fixes measure-live-lane.py picking its test binary alphabetically rather
than by mtime: target/debug/deps keeps every historical build, so a stale one
silently measures the trims of another commit and reports plausible numbers. That
is how a measurement run here reported the state from four PRs earlier (0.76 MB
where the current lane is 0.19 MB).

Docs: CONNECTION.md's history-page table was built from the mixed comparison and
is replaced with the separated one.
@huichen
huichen enabled auto-merge (squash) September 26, 2026 11:25
@huichen
huichen merged commit 01c3057 into main Sep 26, 2026
12 checks passed
@huichen
huichen deleted the fix/measure-page-truth branch September 26, 2026 11:34
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