perf: MD parse_outline_only ~1.7× vs master (post #145) - #147
Closed
tiensonqin wants to merge 4 commits into
Closed
Conversation
Convert page/block-ref and markup scans to while-loops so a long unmatched [[ cannot blow the stack. Build Nested_link in the fast path (depth-capped) instead of falling back to Angstrom, and skip the extra backslash pre-pass. Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Classify lines by first non-space char instead of trying every constructor. Boundary checks no longer fully parse headings or run Inline.parse. Outline properties use the outline inline scanner, titles are scanned in-place, line_starts is skipped, and list/ref recursion is capped. Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
|
|
[[\]]] must still parse as Page_ref "]" — any backslash in the scan range disables the fast path (iterative check, not recursive). Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Reuse page/tag/block-ref nodes and common heading records within a parse. Outline mode indexes newlines and classifies/parses headings from source spans so most lines are never copied into strings. Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Further speed up Markdown
parse_outline_onlyon top of #145. Changes stay inmd_outline.ml/outline_inline.ml(no second document parser, no Parseff, no logseq/logseq bump).Performance (1.2MB
examples/logseq_large.md, 3-iter avg, same machine,dune exec --profile=release ./bench/time_parse.exe)02d6fa1)parse_outline_onlyTarget was ~5× (~0.0047s). That is past the AST floor on this file: outline emits 24 432 blocks. Newline indexing alone is ~0.002s; building those nodes plus interned title inlines is the rest. Previous estimate of a ~2.9× construction floor (~0.008s) still looks right; 5× would require a smaller or lazier AST.
Approach
[[a [[b]]]]in the fast pathInline.parsejust to classify)Inline.parse[[page]]/#tag/((block))nodes and common heading records within one parse (structural=unchanged)[[\]]]still fall back to AngstromTests
dune runtest(markdown, outline markdown, org, zip, export-md, export-opml)dune exec ./bench/time_parse.exevs master, same machine, multiple runsFull parse keeps the existing line-array path (shared cheap classifiers only).