Repository navigation
⚡ perf(markdown): reduce memory used by large Markdown inputs - #2710
Merged
Merged
Conversation
`Option<Position>` shrinks from 40 to 20 bytes, which lowers the size of every node. On a 19.6MB document the peak RSS of `nodes | len` goes from 681MB to 601MB. `Point.line` and `Point.column` are public, so this changes the API of mq-markdown. Parser internals keep `usize` and saturate to `u32::MAX` where a `Point` is built. mq-ffi no longer needs its own saturating conversion.
A `Vec` starts at four elements, so a container with one child held room for four blocks. Nested block vectors are now shrunk once they are complete, which takes the block tree from 267MB to 196MB on a 19.6MB document. `resolve` also copied the whole root vector when appending it into the empty output. It now takes the vector and shrinks it, which lowers the peak during resolution from 506MB to 380MB. Peak RSS of `nodes | len` goes from 681MB to 532MB overall, and the run is about 10% faster.
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
Type of Change
Checklist
cargo fmtandcargo clippyand addressed any warningsjust test-alland all tests pass/docs, crateREADME.md) if neededAdditional Context