Repository navigation
Conversation
3e191e8 to
7df61bc
Compare
f026dad to
a66b1df
Compare
|
A short wrap-up now that the fix has settled (head What ultimately changed. Beyond the headline (weight-budgeted synchronous prefix + time-budgeted background chunks, with the pending tail read live from
Why it took seven rounds. The chunked mount itself was round one; everything after was one consequence surfacing at a time: once the mounted tree stops being the whole document, every scattered place that equated "no next block" with "end of document" becomes subtly wrong — and those assumptions lived in arrow/enter/tab/delete handlers, click handling, footnotes, and history timing. The rounds converged from per-site patches to the shared resolver only after the whole class was mapped, and the final round caught the last coordinate bug in that resolver (receiver-relative instead of frontier-relative advancement). Each finding is now a regression test — 31 in the chunked-mount spec — and the full suite is green at 1478/1478. |
- PR marktext#4946 (includes its base PR marktext#4942): removes the quadratic costs that froze large documents and mounts them progressively — a 2.1 MB document goes from an indefinite freeze to interactive in seconds. Applied verbatim; upstream review addressed 19 findings with 31 regression tests, all passing here. - PR marktext#4931 (marktext#4926): deleting at an offset inside a surrogate pair left a lone surrogate that crashed text-unicode ("Invalid offset - splits unicode bytes"). The content.ts hunk conflicted with our Phase 1 isComposed guards and was integrated by hand; the new cursor snap additionally runs only when no IME composition is open, since moving the DOM selection mid-composition would detach the IME anchor. - PR marktext#4913 (marktext#4899): Shift+Tab outdent with trailing sibling blocks corrupted the state tree (paragraphs appended directly into a list), crashing the next composed op. muya hunks only — the PR's legacy muyajs hunks target the removed engine. - PR marktext#4911 skipped: the equivalent detached-block guard already exists in @muyajs/core's language selector (marktext#4654), verified in source. - PR marktext#4930 (marktext#4921): CodeMirror instance wrapped in a Vue proxy broke source-code mode; markRaw fix applied cleanly. muya suite 1515/1515, tsc/eslint/madge clean. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ef4yFuXFbyKNTazkwUtygY
- PR marktext#4946 (includes its base PR marktext#4942): removes the quadratic costs that froze large documents and mounts them progressively — a 2.1 MB document goes from an indefinite freeze to interactive in seconds. Applied verbatim; upstream review addressed 19 findings with 31 regression tests, all passing here. - PR marktext#4931 (marktext#4926): deleting at an offset inside a surrogate pair left a lone surrogate that crashed text-unicode ("Invalid offset - splits unicode bytes"). The content.ts hunk conflicted with our Phase 1 isComposed guards and was integrated by hand; the new cursor snap additionally runs only when no IME composition is open, since moving the DOM selection mid-composition would detach the IME anchor. - PR marktext#4913 (marktext#4899): Shift+Tab outdent with trailing sibling blocks corrupted the state tree (paragraphs appended directly into a list), crashing the next composed op. muya hunks only — the PR's legacy muyajs hunks target the removed engine. - PR marktext#4911 skipped: the equivalent detached-block guard already exists in @muyajs/core's language selector (marktext#4654), verified in source. - PR marktext#4930 (marktext#4921): CodeMirror instance wrapped in a Vue proxy broke source-code mode; markRaw fix applied cleanly. muya suite 1515/1515, tsc/eslint/madge clean.
a66b1df to
37bd881
Compare
Resolve the lexBlock conflict by keeping LinearMarked with texMathDollars, and update the two PR tests to the renamed option.
Bring in develop and the conflict resolution from PR marktext#4942, preserving LinearMarked and the renamed texMathDollars option.
|
Thank you for the work on this PR and for the careful regression coverage. The measurements below show a useful improvement when opening long documents at the top. They also suggest that parsing costs and restoring a saved document position would benefit from further investigation before we settle on a mounting strategy. For now, I have closed this PR so we can revisit the approach with those scenarios in mind. I ran a local comparison on an Apple M4 Pro with 48 GB RAM, using production Vite bundles in headless Chromium. Each opening scenario was measured five times; the numbers below are medians. The current develop baseline was On current develop, the paragraph fixtures produced:
The fixtures are ASCII, with roughly 40 English words per paragraph. For the largest paragraph fixture, parsing accounts for approximately 73% of synchronous opening time. A separate CPU sample identified repeated remaining-source searches in the multiline-blockquote and block-math extension start hints as the main hotspots. Investigating those paths may be a useful next step alongside the rendering work. This does not mean rendering is free or parsing dominates every document shape. To isolate progressive mounting from other differences between develop and the PR, I also compared this PR against itself with its initial mount budget set to Infinity, forcing synchronous mounting. For the same 10,000-paragraph document, restoring a collapsed caret by block path immediately after setContent gave:
The top-of-document improvement is meaningful. Another important scenario to consider is reopening a document or returning to a tab at a saved position. Restoring near the end synchronously materializes almost the entire prefix, removing most of the scheduling benefit. A single 3,000-item list and a single 1,000-row table also received essentially no benefit because top-level blocks remain atomic. For the top-opening 10,000-paragraph case, waiting for full mounting and the subsequent two animation frames took approximately 1.78 s with forced synchronous mounting versus 2.87 s with progressive mounting. Both ended with 30,001 descendant DOM elements. Progressive mounting changes when the work happens; this experiment does not show reduced final DOM size or faster full completion. Based on these results, I would suggest exploring the parsing hotspots and measuring opening and restoration at the top, middle, and end before choosing the next implementation. Those measurements could help us decide how to build on the progressive-mounting work and whether a strategy that accounts for the restored viewport would be worthwhile. You are very welcome to open a new issue to discuss performance optimization, including these findings, alternative approaches, and representative documents or benchmarks. I would be happy to continue the discussion there. Thank you again for taking on this problem and for the work you have put into it. |
Progressively mount documents with many top-level blocks in #4887, stacked on #4942. The complete logical state is available synchronously; DOM construction starts with a prefix and continues in scheduled chunks. This reduces initial DOM work without claiming to resolve every large-document freeze.
Updated through
37bd8816, on revised #4942 (21418d13). The shared state ownership and History changes live in #4942; the additional commits here implement state-based TOC, progressive mounting, and lifecycle/consumer fixes.Behavior and contracts
null), and cancellation (false): paragraph arrows, code Shift+Enter, and table Enter/ArrowDown abandon canceled requests rather than appending to a replacement/destroyed document. Tab and Delete safely stop on cancellation as well.muya-mount-progress/muya-mount-completedescribe progressive mounts. Small/empty documents mount synchronously without these events; canceled mounts do not emit completion. PublicensureMountedThroughreturns false when its request is invalidated.Limits
The 4 ms check runs between top-level blocks; it is not a task-duration or interaction-latency guarantee. A giant list, table, paragraph, or code block remains atomic. Parsing, browser layout, and synchronous full-tree consumers can still block. Container-internal virtualization is outside this PR.
The original 1.8 s / 9.6 s figures are historical results from an older revision, not current measurements of first paint/input readiness. A new single-sample local comparison mounted 512 of 3000 independent paragraphs initially, while a 3000-item list and 1000-row table still mounted synchronously as single blocks. This illustrates scope, not a universal responsiveness guarantee.
Validation
At
1418941b, the full unit run passed 1934 tests; two existing tests exceeded 5 seconds during concurrent builds, then passed with unchanged timeouts in a single-worker rerun (14 tests across their files). All 1347 specification tests, product TypeScript, scoped lint, circular check, and Muya/desktop builds passed. Existing lint warnings remain.26 Chrome tests passed, covering clipboard, export, search, 10k-paragraph completion, and pending-tail consumers. After the cursor fix, all three progressive-consumer browser tests and 16 Electron integration tests passed again (source mode, tabs/history, TOC, and anchor scrolling).
The final review reproduced a missing combination: frontier Enter + replacement/destruction during a mount callback. Three tests first failed, demonstrating unwanted paragraph insertion.
37bd8816fixes this and adds 20 regression cases across seven exits, including same-document reentrant completion. On that final revision, 131 targeted tests passed across 10 files (mount/cursor/table navigation, true EOF behavior, and arrows); TypeScript and scoped ESLint also passed, with the existing arrow-handler complexity warning. The earlier full-suite/build/browser totals belong to1418941b, not a new full run of the final small patch.