Repository navigation
Parallelize docs builds with sphinx-build -j - #10760
Open
GarrettBeatty wants to merge 1 commit into
Open
GarrettBeatty wants to merge 1 commit into
GarrettBeatty wants to merge 1 commit into
Conversation
* Declare the guzzle theme parallel-safe and build sitemap.xml from the environment so it is complete and ordered like a serial build when writing in parallel. * Add the parallel_chunks extension, which reads with one interleaved chunk per process so the main process does not repeatedly unpickle large environments, and restores the serial document order. * Add the parallel_write extension, which loads, resolves and indexes doctrees in the worker processes and merges search index entries back in chunk order. With sphinx-build -j 16 this builds the docs in ~9.5 minutes instead of ~57 minutes, with output identical to a serial build.
This was referenced Oct 15, 2026
GarrettBeatty
added this pull request to stack #10763
October 15, 2026 14:29
GarrettBeatty
marked this pull request as ready for review
October 15, 2026 14:44
This branch has not been 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.
Description of changes:
Part 1 of 3 (stacked) of the CI build-perf changes from #10759, targeting
feature/build-perf. Speeds up the docs build (the CatapultBuildDocsstep).sphinx-build -j Nbarely helped before because the guzzle theme was not marked parallel-safe and because Sphinx does most of the parallel work in its main process for a doc set this size (~20k pages):guzzle_sphinx_theme: declare the theme parallel-safe, and buildsitemap.xmlfrom the environment (plus pages written by the main process) so it is complete and ordered like a serial build when pages are written in worker processes.parallel_chunks(new extension): while reading, use one interleaved chunk per process. Sphinx otherwise creates ~180 small chunks and the main process unpickles each worker's entire environment, which grows with every chunk. Also restores the serial document order after reading, since it leaks intosearchindex.js.parallel_write(new extension): load, resolve, post-transform and index doctrees in the worker processes instead of the main process, and merge the search index fragments and images back in chunk order. This is the approach from Parallel post transform including write_doc_serialized sphinx-doc/sphinx#11746, specialized for the HTML builder.Both extensions override private Sphinx methods, so they need to be re-validated when upgrading Sphinx (6.2.0 is pinned in
requirements-docs-lock.txt).Testing:
Measured on a c5.9xlarge (same vCPU/memory as CodeBuild
BUILD_GENERAL1_XLARGE): 56.6 min (serial) → 9.4 min with-j 16..buildinfo(which hashes the config), includingsearchindex.jsandsitemap.xml; same warning count.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.