Skip to content

Speed up Writer lookup, typing and Word export and preserve offline drafts - #247

Merged
callumalpass merged 2 commits into
mainfrom
sprint-w8-writer-perf-safety
Nov 28, 2026
Merged

callumalpass merged 2 commits into
mainfrom
sprint-w8-writer-perf-safety

Conversation

@callumalpass

@callumalpass callumalpass commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Refs #248

Changes

  • Rank 5,000-source searches once per library snapshot. Look up citekeys first and stop metadata matching after the result window is filled.
  • Reuse unchanged outline rows and avoid full Markdown scans for word counts in plain prose.
  • Run dependency discovery and warnings for Word and Pandoc exports without also formatting the Typst preview bibliography.
  • Keep drafts backed up while a device write awaits confirmation. If a rejected write is replaced by a remote version, Writer offers the saved local text for review or download.

Benchmark medians

Baseline d10c4ef using the same synthetic fixtures. The preview bibliography uses 100 distinct cited sources out of 5,000 available. Chromium types 22 characters into a 78,762-byte chapter.

Operation Before After
Cold source index and lookup 8.82 ms 6.74 ms
Warm broad source lookup 0.399 ms 0.114 ms
Warm precise citekey lookup 0.508 ms 0.521 ms
Cold APA bibliography 390.0 ms 413.4 ms
Cached APA bibliography 0.066 ms 0.066 ms
Sources query to matching Chromium row 29.6 ms 26.3 ms
Typing input to animation frame 23.2 ms 14.5 ms
Typing renderer main-thread CPU, all 22 inputs 1,139 ms 516 ms
Word export preflight 371 ms 81 ms
Inside Word export handler 2,008 ms 1,789 ms
Chapter save to Word download 3,518 ms 3,236 ms

Three DOCX downloads matched every baseline package part after timestamp normalization. The offline regressions cover disconnected edits, rejected and confirmed device writes, edits made while an earlier write is pending, and reopening during the pending state. The SDK tests use MemoryReplica.

Verification

  • rpnpm check
  • rpnpm build:production
  • rpnpm --filter @mdbase-writer/app typecheck:perf
  • Citation benchmarks and both Chromium profiles, with reproduction commands in apps/writer/scripts/perf/README.md
  • Chromium reliability suite, 24 scenarios passed

@callumalpass
callumalpass merged commit 340d89e into main Nov 28, 2026
1 check passed
@callumalpass
callumalpass deleted the sprint-w8-writer-perf-safety branch November 28, 2026 12:24
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