Skip to content

Speed up Writer outline search and draft checkpointing, and explain save and export failures - #253

Open
callumalpass wants to merge 2 commits into
mainfrom
sprint-w17-writer-ui-search-perf
Open

callumalpass wants to merge 2 commits into
mainfrom
sprint-w17-writer-ui-search-perf

Conversation

@callumalpass

Copy link
Copy Markdown
Member

Refs #113

Writer now reuses the manuscript reading order until its inputs change. Chapter rows retain a stable fold handler when the active chapter changes. Plain paragraphs skip unnecessary decoration work, footnote lookups run on demand, and counting words avoids allocating an array of every word. The Sources panel reuses its keyboard-navigation list across unrelated renders.

I found raw fallback messages in save and export failures, including worker exceptions and Pandoc warning types. Writer now presents recovery text, keeps typed save codes in collapsed technical details, and offers retry after export failure. Image reads that encounter the same pagination failure as the index now return the same user-facing message. Regression coverage checks the exact local draft, an eventual confirmed save, retry to a downloaded ZIP, and both callers of the failed index read.

Measurements

All values are milliseconds. The browser ran Chromium 155.0.8059.84 on a four-vCPU AMD EPYC 9B14 GCP desktop. Each size used seven alternating baseline/candidate pairs with a fresh context per sample. Browser p95 is nearest-rank, which is the maximum of seven. Baseline was 5b22cbf; interactive runs used the performance changes in ab220ef. The final commit changes an index error path and its regression test.

In the 120-chapter SDK fixture, Writer discovers all chapters and 5,000 sources. The pinned SDK accepts the main record and 63 chapter sessions and refuses 57. The browser waits for all 120 outcomes, searches loaded text, checks the 100-reference preview, and verifies the exact 22-character edit in both local storage and the confirmed SDK body. Hydration includes navigation, DEV module loading and fixture seeding. The bibliography column includes preview rendering. The separate mounted React test reads all 120 chapter bodies.

In the large browser case, outline search and typing through the draft checkpoint improved. Chapter switching took longer in both browser sizes with 5,000 sources even though the isolated React switch became cheaper. Hydration was effectively flat. The small control also took longer to filter and checkpoint. The 60-chapter table records the earlier fully loaded comparison before the session-budget message was added.

Mounted 120-chapter outline, 5,000 source keys (ms)

Operation Before median After median Before p95 After p95
Initial stats and mounted outline 164.74 160.69 561.23 329.05
Typing in one chapter 6.51 5.36 8.90 8.31
Switching chapters 22.65 8.04 24.11 10.10
Sparse manuscript search 1.31 1.31 1.32 1.33
Broad manuscript search 2.40 2.41 2.94 2.83

120 chapters requested, 5,000 sources (ms)

Operation Before median After median Before p95 After p95
Navigation → records accounted for, outline count visible 11421.7 11427.9 11554.1 11730.3
Navigation → painted preview and bibliography 13239.8 13171.0 13354.6 13459.0
Open Sources → cited row visible 502.1 492.9 520.8 526.3
Filter → exact source visible 109.2 110.0 152.7 139.8
Outline search → unique match visible 242.2 89.5 474.2 403.5
Switch chapters and return 244.8 316.6 421.5 475.9
Invoke citation completion → options visible 187.7 168.5 198.6 313.4
22 characters → exact draft checkpoint 1213.0 845.4 1336.9 871.3
Renderer CPU during edit and checkpoint 1270.4 803.9 1334.2 844.0
After checkpoint → confirmed body 1077.9 1102.1 1261.1 1161.8

Small control, two chapters and nine sources (ms)

Operation Before median After median Before p95 After p95
Navigation → records accounted for, outline count visible 1229.4 1207.9 1249.1 1244.3
Navigation → painted preview and bibliography 2235.0 2202.3 2261.5 2433.8
Open Sources → cited row visible 388.8 387.9 452.5 403.8
Filter → exact source visible 21.0 25.7 23.0 29.7
Outline search → unique match visible 44.0 40.7 49.8 65.4
Switch chapters and return 191.8 180.0 208.2 553.8
Invoke citation completion → options visible 114.8 120.6 155.1 138.9
22 characters → exact draft checkpoint 617.0 644.4 656.3 681.5
Renderer CPU during edit and checkpoint 602.0 622.1 641.0 654.2
After checkpoint → confirmed body 1247.6 1247.6 1266.1 1297.2

Fully loaded 60 chapters and 5,000 sources, initial comparison (ms)

Operation Before median After median Before p95 After p95
Navigation → records accounted for, outline count visible 11135.7 11137.6 11145.6 11626.9
Navigation → painted preview and bibliography 12772.6 12807.1 12841.1 13399.5
Open Sources → cited row visible 485.6 473.9 493.5 547.3
Filter → exact source visible 121.2 106.8 139.7 139.5
Outline search → unique match visible 137.0 83.9 490.6 484.9
Switch chapters and return 292.5 340.4 370.9 583.9
Invoke citation completion → options visible 166.5 164.7 175.5 241.1
22 characters → exact draft checkpoint 737.1 766.9 799.0 787.5
Renderer CPU during edit and checkpoint 721.7 747.1 761.7 758.4
After checkpoint → confirmed body 1095.1 1084.3 1152.1 1105.7

Reproduce

From the candidate checkout, prepare the baseline and give it the identical fixture and measurement scripts.

git worktree add --detach ../writer-w17-before 5b22cbf
for file in scripts/perf/interactive-profile.mjs scripts/perf/outline.bench.tsx src/backend/large-demo.ts src/ui/DemoRoot.tsx; do
  cp "apps/writer/$file" "../writer-w17-before/apps/writer/$file"
done
pnpm install --frozen-lockfile
(cd ../writer-w17-before && pnpm install --frozen-lockfile)

Start the two servers in separate shells, then run the browser profile from the candidate checkout.

(cd ../writer-w17-before && pnpm -C apps/writer dev --port 5441 --strictPort)
pnpm -C apps/writer dev --port 5442 --strictPort

BASELINE=http://127.0.0.1:5441 BASE=http://127.0.0.1:5442 PROFILE_CHAPTERS=120 \
  pnpm -C apps/writer exec node scripts/perf/interactive-profile.mjs > paired.jsonl

Use PROFILE_CHAPTERS=60 for the fully loaded comparison. Set CHROME to select a Chromium executable. For the mounted outline, run the command below in each checkout seven times, alternating the starting revision. Initial render uses one timing per process. The other mounted rows show the median of seven within-process p50s and p95s, each computed after five warm-ups on twenty measured updates.

rpnpm --filter @mdbase-writer/app test:perf-fixture scripts/perf/outline.bench.tsx

Verification

rpnpm check, rpnpm build:production, and rpnpm --filter @mdbase-writer/app typecheck:perf passed at fa77818. Chromium reliability passed all 25 scenarios on the preceding commit. The final Chromium polish and reliability runs are in progress.

This branch has not been deployed

No deployments
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