Fix for long document load times introduced in v0.35.0#486
Merged
J-F-Liu merged 5 commits intoJ-F-Liu:mainfrom Apr 2, 2026
Merged
Fix for long document load times introduced in v0.35.0#486J-F-Liu merged 5 commits intoJ-F-Liu:mainfrom
J-F-Liu merged 5 commits intoJ-F-Liu:mainfrom
Conversation
…duced in v0.35.0.
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
Removes
nom_locatedependency to fix a performance regression introduced in v0.35.0. See #412 for details.The parser input type was changed from
&[u8]toLocatedSpan<&[u8], &str>in 0.35.0 to carry debug labels through the parser.LocatedSpantracks line/column position by scanning for newlines (viamemchr::count_raw) on every slice operation. For a large PDF, this means millions of redundant newline scans during parsing.Note
Neither the line/column tracking nor the debug labels were ever read.** The only
LocatedSpanmethods actually used (.len(),.take_from(),.fragment()) all have direct equivalents on&[u8].Fix
nom_locatefromCargo.tomlParserInput<'a>fromLocatedSpan<&[u8], &str>back to&[u8]ParserInput::new_extra(bytes, "label")construction sites with plain byte slicestrim_spacessignature, averifyclosure, and cmap_parser test assertionsResult
Loading a 100-page PDF dropped from 9-10 seconds to ~10ms
Test:
tests/document_load_performance.rswithtests/regression/test.pdfWarning
I've included the test.pd for testing but you may not actually want it. I just wanted to point it out because it's quite large. I can remove from the PR if you'd like.