New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize markdown parsing with Kramdown by reusing the options and parser objects #8013
Optimize markdown parsing with Kramdown by reusing the options and parser objects #8013
Conversation
Memory Profile Summary--- master https://travis-ci.org/jekyll/jekyll/jobs/652560205
+++ PR https://travis-ci.org/jekyll/jekyll/jobs/652608908
- Total allocated: 396.41 MB (3625375 objects)
+ Total allocated: 387.31 MB (3599878 objects)
- Total retained: 19.80 MB (107263 objects)
+ Total retained: 19.80 MB (107275 objects) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done @ashmaroli 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say I like this, as it means we're now depending upon implementation details in Kramdown that will come back to bite us the next time we need to upgrade Kramdown.
I'd prefer to not see this merged.
I went and looked at the Kramdown code. It's too simple to require further changes. Would be nice to see something like this pushed upstream if they'll agree to it. |
@jekyllbot: merge +minor |
Awesome!! Thank you very much @mattr- 🎉 |
Summary
Kramdown::Document
is designed to set up the necessary options and a parser (based on the provided options) to initiate conversion of a Markdown content string.But Jekyll uses the same set of options (and therefore the parser as well) to convert all of its Markdown documents. Therefore, having kramdown run the set up tasks for each document is wasteful.
This PR proposes to subclass
Kramdown::Document
and move the set up tasks from the:initialize
method to asingleton_menthod
. This approach has the set up tasks run for just the first Markdown document contents converted, cache the resulting objects and subsequently provide these objects to consequent conversions.