Skip to content
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

Cache SyntaxSet between parse_codeblock calls #147

Merged
merged 1 commit into from
Jan 16, 2024
Merged

Conversation

mgeisler
Copy link
Collaborator

Before we would load and deserialize the syntect syntax trees (Sublime Text syntax definitions) on every call. We now cache this read-only data.

Before, mdbook build took 1.44 s, now it takes 0.56 s instead. I started looking in to optimizing this because I'm considering making mdbook-xgettext an (optional) plugin in book.toml for Comprehensive Rust. This will imply that we run the plugin on every mdbook build — at least for people like me who have the plugin installed.

@codecov-commenter
Copy link

codecov-commenter commented Jan 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ec5968c) 90.64% compared to head (62c36d2) 90.64%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #147   +/-   ##
=======================================
  Coverage   90.64%   90.64%           
=======================================
  Files          11       11           
  Lines        2372     2373    +1     
  Branches     2372     2373    +1     
=======================================
+ Hits         2150     2151    +1     
  Misses        159      159           
  Partials       63       63           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Before we would load and deserialize the `syntect` syntax
trees (Sublime Text syntax definitions) on every call. We now cache
this read-only data.

Before, `mdbook build` took 1.44 s, now it takes 0.56 s instead.
@kdarkhan
Copy link
Collaborator

Just a thought - maybe we should add several bench targets so that we can find how performance of the code changes. Does not have to be exposed during PR build but something that is easy to trigger locally.

@mgeisler
Copy link
Collaborator Author

Just a thought - maybe we should add several bench targets so that we can find how performance of the code changes. Does not have to be exposed during PR build but something that is easy to trigger locally.

That would indeed be a useful tool to have!

For this, I used https://github.com/sharkdp/hyperfine like this:

% MDBOOK_OUTPUT='{"xgettext": {"pot-file": "messages-10.pot", "granularity": 10}}' hyperfine 'mdbook build -d po'

to test only mdbook-xgettext. But if we could put this into a criterion benchmark as well, then that would be nice.

@mgeisler mgeisler merged commit 8ba3c25 into main Jan 16, 2024
7 checks passed
@mgeisler mgeisler deleted the cache-syntax-set branch January 16, 2024 13:31
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.

None yet

3 participants