Skip to content

perf: the analysis chart loads after the page - #331

Merged
ashtonanderson merged 5 commits into
mainfrom
claude/perf-round-8
Nov 3, 2026
Merged

ashtonanderson merged 5 commits into
mainfrom
claude/perf-round-8

Conversation

@ashtonanderson

@ashtonanderson ashtonanderson commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Eighth round: the analysis page's Moves by Rating chart loads after the page instead of with it. Stacked on #329 (claude/perf-round-7); this PR's base is that branch. Details are in LOADING.md ("Round 8").

Change (c16c4fa)

  • Why: recharts and its d3 helpers (~320 KB of JavaScript, uncompressed) were the largest part of the analysis page's start-up code, all for one chart. On desktops the chart is in the sidebar; on phones it's below the board.
  • What: the chart (MovesByRatingArea) now loads with next/dynamic once MovesByRating renders. The panel and its heading draw at once, and a placeholder of the chart's height holds its place.
  • Elsewhere: puzzles, drills, broadcasts and the home page's sections use the same component, so they get the same change.
  • Test: MovesByRating's test renders the chart directly through a mocked next/dynamic, and still checks that the chart redraws only when its moves change.

Results (round 7 → this branch)

Local builds. The phone is Chrome's 4x CPU throttling with 4G. 5 runs each, builds alternating.

analysis phone, first visit desktop
JavaScript at start-up (build, gzip) 417 → 311 kB 417 → 311 kB
Game fully visible 2.65 → 2.56 s 0.65 → 0.59 s
Moves by Rating chart drawn 2.98 → 3.13 s 0.77 → 0.79 s
Main-thread work, first 10 s 6.51 → 6.66 s
  • Game: fully visible sooner in 4 of 5 phone pairs and 5 of 5 desktop pairs.
  • Where the saving comes from: mostly the download. Recharts' code only ran when the chart was drawn, so script time is unchanged. On this emulated 4G (9 Mbps) the 106 kB take about 0.1 s; slower connections save more.
  • Layout: the panel and chart are at the same place and size as before, on a Pixel 7 and at 1440 × 900.

Lighthouse (phone settings, local builds, 3 runs each):

before after
Analysis score 57–66 (median 66) 59–67 (median 64)
Analysis blocking time 2.72 s 2.31 s
Analysis speed index 3.02 s 3.07 s
/puzzles score 42 42

Lighthouse's main content is the board in both builds. Its runs overlap: 2.45–3.91 s before, 2.60–3.44 s after.

Stockfish

Checked with scripts/perf/chart-probe.mjs on the analysis page, 8 steps per run, each pair run in both orders.

round 7 → this branch
Desktop: depth 12 after a step 0.03 ± 0.02 s sooner (sooner on 19 of 32 steps)
Desktop: depth reached before the next step 17.03 → 16.94
Phone: depth 12 after a step 0.23 ± 0.24 s sooner (sooner on 38 of 63 steps)
Phone: steps reaching depth 12 64 → 63 of 64
Phone: depth reached before the next step 14.69 → 14.61

On the phone the build run first in a pair comes out slower:

  • With round 7 run first, the branch was 0.93 s sooner.
  • With the branch run first, it was 0.48 s later.

That's why the order is balanced.

Testing

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
maia-platform-frontend Ready Ready Preview Nov 3, 2026 6:32am UTC

Request Review

ashtonanderson and others added 3 commits November 2, 2026 23:25
recharts and its d3 helpers (~320 KB of JavaScript, the largest part of
the analysis page's) were in the page's start-up code for one chart in the
sidebar, below the board on phones. The chart (MovesByRatingArea) now
loads with next/dynamic once MovesByRating renders; the panel and its
heading draw at once and a placeholder holds the chart's place. The same
goes for puzzles, drills, broadcasts and the home page's sections, which
use the same component. Its test renders the chart directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ashtonanderson and others added 2 commits November 3, 2026 06:30
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rebase on #330 and #332 gave round 8's commit a new ID, and the
old one is no longer on any branch. The round 7 build it was measured
against keeps its old ID, marked as from before the rebase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ashtonanderson
ashtonanderson changed the base branch from claude/perf-round-7 to main November 3, 2026 06:35
@ashtonanderson
ashtonanderson marked this pull request as ready for review November 3, 2026 06:35
@ashtonanderson
ashtonanderson merged commit 3e5ef6d into main Nov 3, 2026
8 checks passed

This branch was successfully deployed

1 active deployment
Preview — f58b8ab5 Deployed Nov 3, 2026 by vercel[bot]
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