Skip to content

ext/imgmath: batch LaTeX compilation - #14535

Open
jschueller wants to merge 1 commit into
sphinx-doc:masterfrom
jschueller:batch
Open

ext/imgmath: batch LaTeX compilation#14535
jschueller wants to merge 1 commit into
sphinx-doc:masterfrom
jschueller:batch

Conversation

@jschueller

@jschueller jschueller commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Add imgmath_batch_size config option (default 1). When set to a value greater than 1, equations are accumulated and compiled in a single LaTeX invocation using a multi-page DVI with preview environments, then split via dvipng -page / dvisvgm --page.

For a build with N equations and batch_size=B, this reduces N LaTeX process launches to ceil(N/B), keeping resource usage manageable.

For the openturns project (with 8k+ equations), this reduces the sphinx build time from 22m30 to 10m25 (with imgmath_batch_size=128)

@jschueller
jschueller force-pushed the batch branch 15 times, most recently from 6c73829 to 8fa3152 Compare July 17, 2026 06:39
@jschueller
jschueller marked this pull request as ready for review July 17, 2026 08:42
@jdillard jdillard added the type:enhancement enhance or introduce a new feature label Jul 31, 2026
Add ``imgmath_batch_size`` config option (default 1). When greater
than 1, equations are collected on ``env-updated`` and compiled into
multi-page DVI documents before writing, reducing N LaTeX processes
to ceil(N/B), then split via ``dvipng -pp`` / ``dvisvgm --page``.

Filenames, embed mode, depth handling, and error reporting match
single-equation mode. Batching is disabled when a custom
``template.tex``/``preview.tex`` template is detected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:enhancement enhance or introduce a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants