Skip to content

Optimize large document interactions - #124

Merged
Renakoni merged 2 commits into
mainfrom
perf/large-document-interactions
Jul 14, 2026
Merged

Renakoni merged 2 commits into
mainfrom
perf/large-document-interactions

Conversation

@Renakoni

Copy link
Copy Markdown
Owner

Summary

  • debounce search input and redraw only the blocks whose active match changed
  • keep exact search counts and navigation above 100 matches while rendering only the active highlight
  • reduce resume-position layout reads from O(n) to O(log n)
  • replace slow Android WebView structuredClone state snapshots with a schema-specific defensive clone
  • cache reference-definition scans by JSON-state revision, removing the measured initialization O(n²) path
  • add a reproducible API 34 large-document probe and benchmark report

Real-device results

Case Before After
1,000-section editor open ~26.8s 1.58s
1,000-match search ~6.4s 0.20s
Next match ~12.5s 9ms
5,000-section editor open ~60.7s 13.26s
10,000-section editor open >120s timeout 45.73s

The final 10,000-section run also measured outline at 3.19s, dense search at 1.54s, next-match navigation at 34ms, and resume persistence at 442ms.

Verification

  • pnpm test (529 passed)
  • pnpm lint
  • pnpm typecheck
  • pnpm --dir third_party/muya run test:app-gate (1,421 passed)
  • ./gradlew :app:testDebugUnitTest
  • search, outline, and resume Playwright coverage passed in the full mobile E2E run
  • API 34 matrix completed at 250, 1,000, 5,000, and 10,000 sections

Notes

The remaining 10,000-section editor-open cost is dominated by Markdown parsing and creation of 30,001 blocks, not the optimized interaction paths. Full profiles and boundaries are documented in refs/large-document-performance-2026-07-14.md.

@Renakoni
Renakoni merged commit 32df788 into main Jul 14, 2026
5 checks passed
@Renakoni
Renakoni deleted the perf/large-document-interactions branch July 14, 2026 13:43
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