Skip to content

perf(markdown): freeze settled section boundaries during streaming - #3801

Merged
wsp1911 merged 2 commits into
openBitFun:mainfrom
Raing5Days:perf/stream-markdown-freezing
Nov 14, 2026
Merged

wsp1911 merged 2 commits into
openBitFun:mainfrom
Raing5Days:perf/stream-markdown-freezing

Conversation

@Raing5Days

@Raing5Days Raing5Days commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Streaming Markdown updates repeatedly tokenize the full document. This change reuses stable leading section boundaries and parses the remaining tail, retaining one section of lookbehind so the trailing block can change safely. Unchanged sections reuse their object identities.

  • Merge current main, preserving separate streaming/settled cache budgets and journal blank-line normalization.
  • Remove the unreachable tailSource.length < SECTION_CHARS shortcut. Tail parsing is still required to detect new HTML, footnotes, and reference definitions that require whole-document rendering.
  • Reuse sections by index instead of repeatedly searching the previous array, and avoid retaining sources rejected by the cache budget.
  • Add streaming regression coverage for parser input size, object reuse, cold-parse equivalence, LF/CRLF/CR, fenced blocks, lists, tables, late document dependencies, replacement content, and journal/settled coordinates.

The optimization needs at least three section boundaries to skip a nonempty prefix. Documents with only two boundaries still parse the full source; this does not claim constant-time updates or a no-tokenization fast path.

Validation

  • Focused Markdown section suites: 19 tests passed.
  • Web UI TypeScript check (pnpm --dir src/web-ui exec tsc --noEmit): passed, reusing the checkout's existing generated API bindings.
  • git diff --check: passed.
  • pnpm run check:web: blocked by an existing main-branch typography audit violation in design-system/packages/ui/src/components/Dialog/Dialog.module.css:77 (--openbitfun-line-height-snug). That file and the audit script are unchanged from main.

Local diagnostic benchmark: approximately 24K characters, 25 append operations per trial, 10 warm-up trials and 30 measured trials (750 samples per implementation). Compared with main, parser-function P50 changed from 0.0485 ms to 0.0228 ms and P95 from 0.0825 ms to 0.0363 ms. These are local Node/Vitest measurements, not native UI frame latency or CI thresholds.

No live Remote Workspace, Remote Control, Peer Device, or Detached Dispatch scenario was exercised; coverage is limited to the shared frontend parser. No protocol or persisted schema changes.

AI-assisted follow-up; locally tested at the parser and TypeScript level, with the broader Web check limitation noted above.

Raing5Days and others added 2 commits November 7, 2026 19:41
Merge main while preserving streaming cache isolation and normalized
blank-line boundaries. Remove the unreachable no-parse fast path,
keep conservative tail parsing, and cover incremental work and semantics.

Focused tests: 19 passed. Web UI TypeScript check passed.
check:web is blocked by the existing Dialog typography audit violation.

AI-assisted follow-up for PR openBitFun#3801.
@wsp1911
wsp1911 merged commit 39941de into openBitFun:main Nov 14, 2026
8 of 9 checks passed
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.

2 participants