[25592] Reduce Read the Docs build time and fix version branch resolution - #1306
Open
rsanchez15 wants to merge 3 commits into
Open
[25592] Reduce Read the Docs build time and fix version branch resolution#1306rsanchez15 wants to merge 3 commits into
rsanchez15 wants to merge 3 commits into
Conversation
Signed-off-by: Raul Sanchez-Mateos <raul@eprosima.com>
cferreiragonz
requested changes
Aug 31, 2026
cferreiragonz
left a comment
Contributor
There was a problem hiding this comment.
LGTM, I would just add one extra protection
| # Read the Docs runs a separate sphinx-build, which imports this file again, for every enabled output | ||
| # format. Cloning the repositories and running doxygen and SWIG once per format would repeat several | ||
| # minutes of work, so the preparation is skipped when a previous run of this build already completed it. | ||
| if ( |
Contributor
There was a problem hiding this comment.
I would also check here that the existing repo is checked out at the correct ref, not only that it exists.
…ected commit Signed-off-by: Raul Sanchez-Mateos <raul@eprosima.com>
cferreiragonz
previously approved these changes
Sep 1, 2026
cferreiragonz
left a comment
Contributor
There was a problem hiding this comment.
LGTM with green CI
cferreiragonz
requested review from
richiprosima
and removed request for
richiprosima
September 1, 2026 14:49
Signed-off-by: Raul Sanchez-Mateos <raul@eprosima.com>
rsanchez15
requested review from
cferreiragonz
and removed request for
richiprosima
September 1, 2026 14:54
Contributor
Author
|
See https://fast-dds.docs.eprosima.com/en/feature-improve-docs-build for a reference build. |
rsanchez15
requested review from
cferreiragonz
and removed request for
cferreiragonz
September 2, 2026 06:14
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
Read the Docs builds of
latest/3.xwere taking around 37 minutes (2248 s, 2199 s, 2244 s on recent builds). The suspicion was that the breathe-generated C++ API Reference was to blame. It is a large cost, but not the main one: the build was paying for the same work four times over.Read the Docs runs a separate
sphinx-buildper output format, andreadthedocs.yamlrequestedformats: all. The build log of alatestbuild shows where the 37 minutes go:python -m sphinx -b htmlpython -m sphinx -b singlehtml(htmlzip)python -m sphinx -b latex(pdf)python -m sphinx -b epublatexmk93% of the wall time is those four Sphinx invocations. Since each one imports
docs/conf.pyagain, the preparation done there also ran four times: the log containsRead the Docs environment detected!,Cloning Fast DDS,Cloning Fast DDS Python BindingsandConfiguring Doxyfile4x each, plusRemoving existing repository in ...6 times — runs 2 to 4 deleted and re-cloned Fast DDS (149 MB of history, no--depth) and Fast DDS Python, and re-ran doxygen and SWIG.PR builds only took ~13 min because Read the Docs skips additional formats for external versions.
This PR contains four changes:
1. Build only HTML, and generate the downloadable documentation from it (
readthedocs.yaml)formats: all->formats: [htmlzip]. Thelatexandepubruns andlatexmkare removed: -929 s (~15.5 min). The PDF and epub downloads disappear from the Read the Docs flyout menu.htmlzipis kept, as it is the format that provides the downloadable documentation for offline reading.By default,
htmlzipis not a copy of the HTML output: Read the Docs generates it with an extrasphinx-build -b singlehtmlrun, that is, by building the whole documentation a second time (491.2 s in the log above). Sincehtmlis built first and its output is already the complete documentation,build.jobs.build.htmlzipis overridden to compress that output instead:491.2 s -> ~1 s, and the downloaded file becomes the whole documentation site, navigation and search included, instead of a single page. Only the
htmlzipjob is overridden; every other format keeps its default command.2. Stop generating doxygen output that nothing consumes (
code/doxygen-config.in)XML_PROGRAMLISTINGYESNO<programlisting>elements. None of the 492 directives used in the API Reference renders program listings. XML: 33 MB -> 22 MB.GENERATE_HTMLYESNO@PROJECT_BINARY_DIR@/html/doxygenand never published:html_extra_pathis commented out,CMakeLists.txtinstalls onlydoxygen/xml, and no.rstfile links intodoxygen/.SEARCHENGINEYESNOThe API Reference is unaffected: breathe consumes the XML output, which is still generated.
3. Clone Fast DDS cheaply, and prepare it once per build (
docs/conf.py)resolve_remote_ref()resolves the branch or tag withgit ls-remote, without downloading anything, so falling back to master when the remote does not have the wanted ref costs nothing.clone_repo_at_ref()then clones it with--depth 1 --single-branch, which is all doxygen and SWIG need — 4.5 MB and 1.6 s instead of 149 MB of history.The
shutil.rmtree+ re-clone on every import is replaced by a reuse check: the clone, doxygen and SWIG steps are skipped when the repositories are already checked out at the expected commit (repo_is_at_commit(), comparingHEADagainst the commit resolved above) anddoxygen/xml/index.xmland the SWIG wrapper are already in place. So thehtmlziprun reuses everything thehtmlrun prepared instead of repeating it.4. Build the API Reference from the right branch (
docs/conf.py)Unrelated bug found in the same logs: on the
latest(3.6.x) build,get_git_branch()returnsNonefor thelatestpseudo-name, so the log readsCurrent documentation branch could not be determinedfollowed byChecking out Fast DDS branch "origin/master". The 3.6.x API Reference was therefore generated from Fast DDS master headers, and the GitHub links pointed at master.get_git_branch()now prefers Read the Docs'READTHEDOCS_GIT_IDENTIFIER(the ref actually checked out, e.g.3.6.x) for thelatestandstablepseudo-names. The value is validated against the remote by change 3, so an unexpected value still falls back to master exactly as before.Result
htmlzip)latest/3.xbuild on Read the DocsThe estimate for
latestis thehtmlrun with 16.4% off (~615 s), about a second of compression, and the ~70 s of environment setup.Verification
colcon build --packages-select fastdds-docssucceeds,build succeededwith no warnings.fastdds/api_referenceHTML pages are byte-identical before and after the doxygen changes (51,136,889 bytes either way), compared with the same command and a fresh doctrees directory.resolve_remote_ref()was exercised against the real remotes for an existing branch (3.6.x), an existing tag (v3.6.1), a ref that only tail-matches an unrelated branch, and an absent ref: the first two are used with their commit, the last two fall back to master without failing.repo_is_at_commit()returnsTrueonly for a clone at the expected commit, andFalse, with a printed reason, for a clone at a different commit, a missing directory, a directory that is not a repository, and an unresolved commit.htmlzipcommands were run against a real HTML output: 1.1 s to compress 98 MB into a 15 MB archive that unzips into a browsable site with the 559 pages, the 350 API Reference pages, the static assets,searchindex.jsand the images. The build log confirms Read the Docs builds thehtmlformat first, so its output is in place when thehtmlzipjob runs.get_git_branch()was exercised for alatestbuild tracking3.6.x(now resolves to3.6.x), alatestbuild with noREADTHEDOCS_GIT_IDENTIFIER(stillNone, unchanged), and anexternalPR build (stillNone, so the PR number is never used as a ref).Not included
Moving
fastdds/api_referenceinto its own Read the Docs subproject. It is the biggest remaining lever — the API Reference is 65% of each Sphinx run (262 s of 405 s locally; excluding it drops the build to 143 s) — but it requires intersphinx to keep the ~1000:cpp:aliases indocs/03-exports/aliases-api.includeresolving from the prose, so it is left for a separate discussion.Contributor Checklist
Proversion badge has been added if the documented feature is exclusive to Fast DDS Pro.Reviewer Checklist