Performance¶
Concurrency¶
Documents are rendered concurrently: by default, twice as many at a time as there are CPUs, up to 8 (rendering mostly waits for the browser, which then uses about 1.4 GB of memory). The number can be set, e.g. to use less memory:
plugins:
- exporter:
formats:
pdf:
concurrency: 4
Cache¶
Documents are kept in .cache/plugin/exporter (next to your configuration file) and reused by the next builds as long as their page, the plugin's version and options, the browser's version and the files they load from your website (stylesheets, scripts, images...) are unchanged. Files loaded from other websites (e.g. a script from a CDN) are assumed not to change: delete the directory to start afresh.
Documents that may be incomplete (a file failed to load, a hook failed) are not kept, and the cache only keeps the documents of the last build. Books are printed on every build. The cache can be moved, or disabled:
plugins:
- exporter:
formats:
pdf:
cache:
enabled: false
directory: .cache/plugin/exporter
Generating documents faster¶
- Documents are not generated by
mkdocs serveby default; disable them for regular builds too with an environment variable (enabled: !ENV [MKDOCS_EXPORTER_PDF, true]). - Keep the cache between builds (on CI too): only the pages that changed are rendered again.
- Documents are rendered twice as many at a time as there are CPUs (up to 8): raise
formats.pdf.concurrencyon large machines with memory to spare (16 documents at a time are a few percent faster), lower it if the browser runs out of memory. - Books are printed once more as a whole (twice with a table of contents,
start: oddor{section}, the first print only laying the document out): leave out the books you don't need (enabled: false). - Tables of contents and
{section}in headers and footers make documents of pages printed twice. - If you added Paged.js, keep in mind that it lays out pages much more slowly than the browser.