Repository navigation
perf(site): cut forced style recalcs on load - #62421
Merged
Merged
Conversation
…the top The scroll handler wrote --banner-scroll on the site root on mount and on every scroll event, then read layout right after the write. A page loaded at the top now writes nothing (unset reads as 0px), unchanged values aren't rewritten, and the reads come first. strobe: load-home main.work -5.4% desktop, -5.9% phone (exp_4c3ca9); scroll unchanged.
The field drew its dot mask from an effect on mount (forcing a layout) and again from the resize observer's first callback. The observer's callback is now the first draw, before the same frame paints. strobe: load-home main.work -2.6% desktop (exp_441606); phone underpowered.
adamdotdevin
enabled auto-merge (squash)
November 6, 2026 20:30
Contributor
There was a problem hiding this comment.
I didn't find anything that should block this. I couldn't run it in a browser (none available here), so the strobe numbers aren't reproduced. typecheck:tsc and bun test (178 pass) succeed in services/site.
From the code:
- Banner: reading layout before the write, and starting from
0pxto match the CSS fallback, works with the existing cleanup that removes--banner-scroll. A remount can't keep an old value, and a page restored partway down still writes on mount. - Console dots: deferring the
doteffect is safe, because aResizeObserveralways calls back once for a newly observed element, so the first draw still happens. - Strobe tooling: the benches,
perf/serve.ts,strobe.jsonand theSTROBE_SOURCEMAP-gated sourcemap are dev-only and leave production builds unchanged.
Public API: unchanged.
This was referenced Nov 6, 2026
autonull
pushed a commit
to autonull/opencode_spacegraph
that referenced
this pull request
Nov 7, 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.
Issue for this PR
Closes #
Type of change
What does this PR do?
Two places forced extra full-page style recalculations while the home page hydrates:
site-banner.tsx): its scroll handler ran on mount and wrote--banner-scrollon the site root (an inherited custom property, so the whole page restyles), then read layout straight after the write. A page loaded at the top now writes nothing (unset already reads as0pxthrough the CSS fallback), unchanged values aren't rewritten, and the reads come before the write.console-field.tsx): the dot mask was drawn from an effect on mount (forcing a layout) and again in the resize observer's first callback. The observer's callback is now the first draw; it runs after layout and before that frame paints, so the dots appear in the same frame as before.Also adds strobe benches for the site (
services/site/perf/site.bench.ts,perf/serve.ts,services/site/strobe.json),@hona/strobeas a site devDependency, andsourcemap: "hidden"for client builds only when strobe setsSTROBE_SOURCEMAP=hidden. All of that is dev-only: production builds and the scripts they ship are unchanged.Discovery:
strobe bench services/site/perf/site.bench.ts --check --why always --headless, thenstrobe query <rec> layouton the home load. That showed about 10 forced style recalcs per load, withsite-banner.tsx:73(scrollY after the write) andconsole-field.tsx:22(clientWidth) among them.How did you verify your code works?
/main-thread work −5.4% desktop, −5.9% phone; scroll unchanged. Console dots: load/−2.6% desktop; phone underpowered.site-qa/parity.ts, 53 routes × 3 viewports with forced states) against origin/dev: no differences beyond the documented logo-wall timing noise (/ja,/de, which also needed retries base-vs-base).bun typecheck,bun run typecheck:tsc,bun testinservices/site; rootbun run check; the build's bundle and CSS checks.Visual
Checklist
strobe · exp_4c3ca9 · services/site/perf/site.bench.ts · generated
5.4–5.9% less main-thread work
Caution
Regression: late frames rose from 23.5% to 31.6% in Load home (desktop) (3 of 3 pairs)
Regression: late frames rose from 31.9% to 39.1% in Load home (phone) (7 of 10 pairs)
Regression: late frames rose from 20.1% to 22.2% in Scroll home (desktop) (17 of 26 pairs)
Load home (desktop): Main-thread work per 973 ms run −5.4% per pair (medians 535 → 508 ms), better in 8 of 8 pairs, likely −9.8% to −3.5%.
Load home (phone): Main-thread work per 1 s run −5.9% per pair (medians 669 → 617 ms), better in 10 of 12 pairs, likely −11% to 0.0%, perhaps by under 2%; unsteady case: its work grew each run.
Scroll home (desktop): Main-thread work per 2.1 s run: no clear change in 26 pairs (medians 701 → 692 ms); ~46 pairs would settle it.
Measured in a headless browser (no display): CPU and counters only; compare only with other headless runs.
Details · metrics, pairs, profiles, method
Metrics
Likely range: 98.4% confidence for the main metric, 96.1% for the others. Change: the median of the pairs' own changes.
Pairs
Each pair launched both builds fresh, in alternating order (AB or BA). Change: the main metric. The … row of Scroll home (desktop) sums up pairs 6–21: this PR did better in 10 of 16; the middle 80% of their changes ran from −4.7% to +2.6%.
Frame pacing: Load home (desktop)
Shares of all 409 and 298 gaps between frames; a frame is late from 1.5 frame times. Gap percentiles: each launch's own, median across launches.
Frame pacing: Load home (phone)
Shares of all 746 and 668 gaps between frames; a frame is late from 1.5 frame times. Gap percentiles: each launch's own, median across launches.
Frame pacing: Scroll home (desktop)
Shares of all 11,513 and 11,374 gaps between frames; a frame is late from 1.5 frame times. Gap percentiles: each launch's own, median across launches.
Where it came from, in profiled launches
rsite.jsnsite.jsrsite.jsaindex.js(V8 API)(native)rsite.jsnsite.js(V8 API)(native)From one profiled launch per build (
rec_6fa396→rec_d69158,rec_9d4147→rec_dcf979), apart from the timed pairs: only what moved the way a decided change did, to explain it. Profiling slows a launch, so read these as directions, not as changes.How it was measured
origin/dev@e9540d35d4, fix(core): stop waiting on the Console before promptsdfe7fec2ae, perf(site): stop the banner's scroll handler forcing a page restyleAlso measured, not tested
Unchanged: DOM nodes (3, 1534), JavaScript heap (0.600 MB). Uneven pairs: JavaScript time per run in Load home (desktop) read 22.2–26.7 ms before and 22.4–26.6 ms with this PR, CPU time per run in Load home (desktop) read 989 ms–1.14 s before and 912 ms–1.10 s with this PR, GPU process CPU use in Load home (phone) read 10.4–21.3% before and 9.25–21.9% with this PR, app memory in Load home (phone) read 791–1222 MB before and 813–1063 MB with this PR and JavaScript heap in Scroll home (desktop) read 9.96–24.7 MB before and 9.97–22.6 MB with this PR; the medians' change (beside it) and the pairs' own point different ways, as when a few launches read far from the rest, so read neither as the change.
Rerun · command and recordings
strobe bench services/site/perf/site.bench.ts \ --base origin/dev \ --head dfe7fec2ae \ --filter load-home,scroll-home \ --headless \ --max-time 30m \ --target desktop,phone # to settle Scroll home (desktop) (~46 pairs), add: --filter scroll-home --pairs 46strobe report experiment exp_4c3ca9 --openstrobe open exp_4c3ca9/head,strobe open exp_4c3ca9/baserec_75a3e2(before, pair 1),rec_e257b1(this PR, pair 1)rec_f6dc71(before, pair 1),rec_21eb7a(this PR, pair 1)rec_a31dcf(before, pair 1),rec_a1b93e(this PR, pair 1)strobe · exp_4c3ca9 · end of generated report
strobe · exp_441606 · services/site/perf/site.bench.ts · generated
2.6% less main-thread work
Caution
Regression: late frames rose from 35.3% to 38.7% in Load home (phone) (5 of 11 pairs)
Load home (desktop): Main-thread work per 797 ms run −2.6% per pair (medians 494 → 477 ms), better in 10 of 12 pairs, likely −4.2% to −1.0%, perhaps by under 2%.
But GPU process CPU use +17% and JavaScript time per run +8.2% (not tested).
Load home (phone): Main-thread work per 909 ms run: no clear change in 18 pairs (medians 589 → 581 ms); ~118 pairs would settle it.
But JavaScript time per run +5.4% (not tested).
Measured in a headless browser (no display): CPU and counters only; compare only with other headless runs.
Details · metrics, pairs, profiles, method
Metrics
Likely range: 98.8% confidence for the main metric, 95.8% for the others. Change: the median of the pairs' own changes.
Pairs
Each pair launched both builds fresh, in alternating order (AB or BA). Change: the main metric.
Frame pacing: Load home (desktop)
Shares of all 418 and 484 gaps between frames; a frame is late from 1.5 frame times. Gap percentiles: each launch's own, median across launches.
Frame pacing: Load home (phone)
Shares of all 904 and 926 gaps between frames; a frame is late from 1.5 frame times. Gap percentiles: each launch's own, median across launches.
Where it came from, in profiled launches
aindex.jsFrom one profiled launch per build (
rec_da1711→rec_da72db), apart from the timed pairs: only what moved the way a decided change did, to explain it. Profiling slows a launch, so read these as directions, not as changes.How it was measured
170d9ed4bf, perf(site): write a fixed mark's surface only when it changes04eee9d30b, perf(site): draw the Console dots once when the field mountsAlso measured, not tested
Unchanged: DOM nodes (3), JavaScript heap (0.600 MB). Uneven pairs: layout time per run in Load home (desktop) read 27.6–35.9 ms before and 29.9–37.8 ms with this PR, app memory in Load home (desktop) read 754–1094 MB before and 723–1141 MB with this PR and layout time per run in Load home (phone) read 25.9–35.0 ms before and 26.4–32.1 ms with this PR; the medians' change (beside it) and the pairs' own point different ways, as when a few launches read far from the rest, so read neither as the change.
Rerun · command and recordings
strobe bench services/site/perf/site.bench.ts \ --base 170d9ed4bf \ --head 04eee9d30b \ --filter load-home \ --headless \ --max-time 25m \ --target desktop,phone # to settle Load home (phone) (~118 pairs), add: --filter load-home --pairs 118strobe report experiment exp_441606 --openstrobe open exp_441606/head,strobe open exp_441606/baserec_e2309b(before, pair 1),rec_abd4c2(this PR, pair 1)rec_b3d2ea(before, pair 1),rec_e25116(this PR, pair 1)strobe · exp_441606 · end of generated report