Repository navigation
Reuse search entries of unchanged pages in mkdocs serve - #20
Merged
Merged
Conversation
The search plugin parsed the HTML of every page again on each serve rebuild, which took about a third of the rebuild time on large sites. With mkdocs-ng 1.11, keep the entries of a page in mkdocs' render cache, keyed on everything they are computed from, and reuse them while the page is unchanged. The search index is byte for byte the same. With 1,000 pages, an edited page shows up after 4.1 s instead of 5.9 s.
Merged
This branch was previously deployed
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.
On every
mkdocs serverebuild, the search plugin parsed the HTML of every page again withHTMLParser. On a 1,000-page site that took about 1.8 s of a 5.7 s rebuild, even when only one page changed.mkdocs-ng 1.11 keeps a render cache during
mkdocs serve(mkdocs.structure.render_cache, mkdocs-ng#131 and #145), and its own search plugin already reuses entries throughRenderCache.memo. This does the same for Material's search plugin. The key holds everything the entries are computed from: the page URL, title, HTML, TOC, thetitle,tagsandsearch.boostfront matter, and the jieba settings. With older mkdocs-ng, or withmkdocs build, nothing changes.Measured on the 1,000-page benchmark site (4 cores):
search/search_index.jsonfrom the serve rebuild is byte for byte the same as from a clean buildChangelog: added a
9.8.1 Unreleasedentry indocs/changelog/index.mdandCHANGELOG.