Repository navigation
Measure the resting rail entry only for a row the rail could hold - #2802
Merged
Merged
Conversation
`layoutMarginRows` read a rail entry's width on every pass, and with no live rail entry `restingRail()` inserts a measuring clone and removes it, restyling the whole document twice and forcing a third restyle at the pass's next read. The width feeds only `rowPosture`, which answers "pin" without it wherever the rail does not stand or does not stand beside the target's scroller. On a page whose rows are all pins, every pass paid for it: a thread step (`t`) runs two passes. The pass now reads the width lazily, once, for the first row the rail stands beside. Pin pages, and rail pages with no rows, no longer clone; a rail page's first comment still measures the native primitive, as the `restingRail` contract requires. Thread step median on a 104-thread page, headless Chrome, 5 runs x 8 steps: bare `<main>` (all pins) 186 -> 82 ms; `layout-column` (rail rows) 75 -> 69 ms. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 14, 2026
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.
On a page where every margin row is a pin, each thread step (
t) spent about 100 ms restyling the whole document for a width it never used.layoutMarginRowsreads a rail entry's width at the start of every pass, and with no live rail entryrestingRail()inserts a measuring clone and removes it, two whole-document restyles (about 3,070 elements on the test page) plus a third at the pass's nextskipped()read. A step runs two passes. The width feeds onlyrowPosture, which returns"pin"without it wherever the rail does not stand or does not stand beside the target's scroller. The path came in with #2252.The pass now reads the width lazily, once per pass, for the first row the rail stands beside. Pin pages, and rail pages with no rows, no longer clone; a rail page's first comment still measures the native primitive, as
restingRail's contract above it requires.I did not cache the measurement per viewport and theme. The comment on
restingRailrules out a cached size, since the allocation comes from the live cascade, package and author overrides included, and a revision can change those without a resize or theme switch. After this change the clone runs only on a rail page that has no rail row yet, or whose rows have all pinned (blocks wider than the rail's inner edge, or sidenotes level with them), so a cache would buy little and add an invalidation rule.Thread step median, 104-thread page, headless Chrome 153 at 1440x900, 5 runs x 8 steps from the top of a fresh page, keydown to the first painted frame showing the thread:
<main>(every row a pin)layout-column(rail rows)Tests run:
pnpm run test:runtime(419 pass); the margin rail/pin posture, first-rail-allocation, sidenote and pin-seating tests intests/browser/test_render_margin.py, and the thread-walk and thread-travel tests intests/browser/test_render_navigation.py(33 pass).