Repository navigation
[doc] rtd: run a clean build for PR previews instead of the cache - #64599
Merged
edoakes merged 2 commits intoJul 8, 2026
Merged
Conversation
The incremental-from-master-cache path for PR previews downloads the master doctree cache but Sphinx discards it on every build (a config value differs between the cache producer and the RtD build environment), so it rebuilds all docs anyway while paying the download/extract cost and risking a second clean build on fallback. A clean build is faster and lower-variance in practice. Collapse the build.html override so PR previews and branch/tag builds both run a full clean `make -C doc html`. The rtd/rtd-fallback targets and load_doc_cache.py stay in the tree for a later re-enable, once cache reuse is confirmed and stale-artifact pruning lands for rename/delete PRs. Signed-off-by: Douglas Strodtman <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request simplifies the Read the Docs configuration in .readthedocs.yaml by disabling the incremental build path from the master doc cache and reverting to a full clean Sphinx build for all builds (including PR previews and branch/tag builds). This change addresses issues where Sphinx discarded the restored cache due to environment mismatches, making clean builds faster and more reliable. There are no review comments, and I have no feedback to provide.
dstrodtman
marked this pull request as ready for review
July 8, 2026 20:07
elliot-barn
approved these changes
Jul 8, 2026
400Ping
pushed a commit
to 400Ping/ray
that referenced
this pull request
Aug 18, 2026
…y-project#64599) ## Why The incremental RtD PR-preview build (added in ray-project#64277) isn't paying off, and a clean build is faster and lower-variance in practice. Opening as a draft for @ronny-anyscale to review, since this is your workstream. Present-state evidence from read-only RtD build logs (project `anyscale-ray`, 2026-07-08): - Every PR preview downloads the master doctree cache successfully, then Sphinx discards all of it and rebuilds every document: ``` Use build cache for commit 1319e11... updating environment: [config changed ('intersphinx_mapping')] 3968 added, 1 changed, 0 removed ``` `3968 added` = full rebuild. The discard reason has moved from `[new config]` (the version-skew fixed by ray-project#64414/ray-project#64482) to `[config changed ('intersphinx_mapping')]` / `[config changed ('llms_txt_exclude')]` — a config value that differs between the postmerge cache producer and the RtD build environment. - So the cache download and extract are pure overhead, and when the incremental leg trips a warning the build does a second full clean build (near 2× wall-clock). - Measured: clean full builds land at ~7–9 min (master builds 418–525s), faster than most PR "incremental" builds (466–1195s, median ~640s). Turning the incremental leg off reduces both wall-clock and shared-slot queue pressure versus today. ## What this changes Collapses the `build.jobs.build.html` override so every build — PR previews and branch/tag builds alike — runs a full clean `make -C doc html`. The `rtd` / `rtd-fallback` Makefile targets and `doc/load_doc_cache.py` stay in the tree so the incremental path can be re-enabled later. ## Re-enable criteria (not in this PR) 1. Cache reuse actually works — a PR preview logs `N changed` rather than `NNNN added` — which needs the config-determinism gap closed (`intersphinx_mapping`, `llms_txt_exclude`, and any other env-signature config that differs between producer and RtD). 2. Stale-artifact pruning lands for PRs that rename/delete sources, so incremental previews don't publish stale pages. The `post_checkout` skip guard (skip PR builds that don't touch doc-affecting files) is unchanged — it's orthogonal and still valuable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Douglas Strodtman <[email protected]> Signed-off-by: 400Ping <[email protected]>
dstrodtman
added a commit
that referenced
this pull request
Aug 21, 2026
## Summary
Read the Docs builds intermittently fail with a bare `EOFError` and no
failing document named:
```
File ".../multiprocessing/connection.py", line 399, in _recv
raise EOFError
EOFError
make: *** [Makefile:91: html] Error 2
```
The kernel OOM-kills one of Sphinx's parallel write workers, and the
parent process has nothing better to report than the broken pipe. This
caps the worker count on the Read the Docs builder, which is the only
builder with a hard memory ceiling.
Two changes:
- `doc/Makefile` gains `SPHINX_JOBS ?= auto`, feeding `sphinx-build -j`.
The default keeps today's behavior for every existing caller.
- The `.readthedocs.yaml` html job passes `SPHINX_JOBS=2`.
## The mechanism
The builder has 4 CPUs and a cgroup `memory.max` of 7,130,316,800 bytes,
about 6.64 GiB, which matches the memory limit Read the Docs documents
for Business. `-j auto` forks one write worker per CPU and each worker
carries its own copy of the build environment, so the write phase costs
memory in proportion to the job count.
Measured on the builder, with `memory.events` read immediately after the
build:
| Job count | `memory.peak` | Headroom under the ceiling | `oom_kill` |
Result |
|---|---|---|---|---|
| `auto` (4) | 6,371,254,272 | ~759 MB | 1 | failed, `EOFError` |
| `auto` (4) | 6,503,370,752 | ~627 MB | 0 | passed |
| 2 | 5,566,427,136 | ~1,564 MB | 0 | passed |
The two `-j auto` rows are the important pair: the run that was killed
peaked *lower* than the run that passed. There is no threshold being
crossed. The build simply runs about 600 MB under a hard ceiling with
four workers allocating independently, and whether a given run survives
depends on the timing of individual allocations. That is also why the
document Sphinx dies on moves between builds, which is what makes the
failure read as a content problem when it isn't.
Dropping to 2 workers roughly doubles the headroom, from about 600 MB to
about 1.5 GiB.
## Why this is worth doing rather than waiting
The parallelism is recent, not long-standing. Read the Docs' own Sphinx
invocation adds `-j auto` only for projects carrying the opt-in
`BUILD_IN_PARALLEL` feature flag, so RtD was building Ray's docs
serially. #64277 pointed `build.jobs.build.html` at `make -C doc html`,
which inherited the Makefile's `-j auto` — a flag that until then only
the Buildkite doc build used. #64599 then made every preview a full
clean `-a -E` build. Neither change was wrong on its own; together they
put four write workers and a thin memory margin on the one builder that
can't absorb them.
Some things that this is *not*, all checked:
- **Not content growth.** The Sphinx environment went from 4058
documents on a passing build to 4087 on a failing one. 0.7% can't move a
build across a ceiling.
- **Not dependency drift.** `doc/requirements-doc.lock.txt` is fully
hash-pinned and unchanged across the window.
- **Not worker overcommit.** Sphinx resolves `-j auto` through
`multiprocessing.cpu_count`, which is neither affinity- nor
cgroup-aware, so it can in principle fork more workers than the
container can run. On this builder `nproc` and `nproc --all` both report
4, so that isn't happening.
- **Not host contention.** The ceiling is a per-build cgroup limit, not
host pressure, so this isn't other builds crowding the machine.
## Cost
Wall clock. A paired run on one builder measured 349 seconds at `-j
auto` against 620 seconds at `SPHINX_JOBS=2`, about 78% slower. The
`SPHINX_JOBS=2` arm ran with a warm cache, so treat 78% as a lower
bound.
That cost is confined to Read the Docs. `SPHINX_JOBS` defaults to
`auto`, so local builds and the Buildkite doc build are untouched.
Verified with `make -n`: the default still renders `-j auto`, the
override renders `-j 2`, and because `RTDSPHINXOPTS` and `LINKCHECKOPTS`
derive from the same variable, the override also reaches `linkcheck`,
`rtd-build`, and `rtd-fallback`. That last part matters for when the
incremental cache path in #64277 is re-enabled — the cap will apply
there too without another change.
## Why 2 rather than 3
2 is the value with a measured peak and a clean `oom_kill 0`. 3 would
cost less wall clock and is plausibly enough, but it hasn't been
measured, and at 3 workers the expected headroom lands between the two
figures above, closer to the margin that is already producing
intermittent kills. Given the failure mode is timing-dependent rather
than threshold-dependent, the point of the change is durable headroom
rather than getting just back under a line. If the wall-clock cost
proves painful, 3 is the obvious thing to measure next.
## Follow-up
Read the Docs documents the memory limit as upgradable on Business.
Raising it would let the parallelism come back and undo the wall-clock
cost. That's a separate ask to Read the Docs rather than a change in
this repo, and it's worth making regardless of this PR.
#65631 is the measurement PR that produced the numbers above. It can be
closed once this lands; the `SPHINX_JOBS` plumbing it carried is
included here, and its diagnostic wrapper was always meant to come back
out.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: Douglas Strodtman <[email protected]>
nadongjun
pushed a commit
to nadongjun/ray
that referenced
this pull request
Oct 6, 2026
…project#65643) ## Summary Read the Docs builds intermittently fail with a bare `EOFError` and no failing document named: ``` File ".../multiprocessing/connection.py", line 399, in _recv raise EOFError EOFError make: *** [Makefile:91: html] Error 2 ``` The kernel OOM-kills one of Sphinx's parallel write workers, and the parent process has nothing better to report than the broken pipe. This caps the worker count on the Read the Docs builder, which is the only builder with a hard memory ceiling. Two changes: - `doc/Makefile` gains `SPHINX_JOBS ?= auto`, feeding `sphinx-build -j`. The default keeps today's behavior for every existing caller. - The `.readthedocs.yaml` html job passes `SPHINX_JOBS=2`. ## The mechanism The builder has 4 CPUs and a cgroup `memory.max` of 7,130,316,800 bytes, about 6.64 GiB, which matches the memory limit Read the Docs documents for Business. `-j auto` forks one write worker per CPU and each worker carries its own copy of the build environment, so the write phase costs memory in proportion to the job count. Measured on the builder, with `memory.events` read immediately after the build: | Job count | `memory.peak` | Headroom under the ceiling | `oom_kill` | Result | |---|---|---|---|---| | `auto` (4) | 6,371,254,272 | ~759 MB | 1 | failed, `EOFError` | | `auto` (4) | 6,503,370,752 | ~627 MB | 0 | passed | | 2 | 5,566,427,136 | ~1,564 MB | 0 | passed | The two `-j auto` rows are the important pair: the run that was killed peaked *lower* than the run that passed. There is no threshold being crossed. The build simply runs about 600 MB under a hard ceiling with four workers allocating independently, and whether a given run survives depends on the timing of individual allocations. That is also why the document Sphinx dies on moves between builds, which is what makes the failure read as a content problem when it isn't. Dropping to 2 workers roughly doubles the headroom, from about 600 MB to about 1.5 GiB. ## Why this is worth doing rather than waiting The parallelism is recent, not long-standing. Read the Docs' own Sphinx invocation adds `-j auto` only for projects carrying the opt-in `BUILD_IN_PARALLEL` feature flag, so RtD was building Ray's docs serially. ray-project#64277 pointed `build.jobs.build.html` at `make -C doc html`, which inherited the Makefile's `-j auto` — a flag that until then only the Buildkite doc build used. ray-project#64599 then made every preview a full clean `-a -E` build. Neither change was wrong on its own; together they put four write workers and a thin memory margin on the one builder that can't absorb them. Some things that this is *not*, all checked: - **Not content growth.** The Sphinx environment went from 4058 documents on a passing build to 4087 on a failing one. 0.7% can't move a build across a ceiling. - **Not dependency drift.** `doc/requirements-doc.lock.txt` is fully hash-pinned and unchanged across the window. - **Not worker overcommit.** Sphinx resolves `-j auto` through `multiprocessing.cpu_count`, which is neither affinity- nor cgroup-aware, so it can in principle fork more workers than the container can run. On this builder `nproc` and `nproc --all` both report 4, so that isn't happening. - **Not host contention.** The ceiling is a per-build cgroup limit, not host pressure, so this isn't other builds crowding the machine. ## Cost Wall clock. A paired run on one builder measured 349 seconds at `-j auto` against 620 seconds at `SPHINX_JOBS=2`, about 78% slower. The `SPHINX_JOBS=2` arm ran with a warm cache, so treat 78% as a lower bound. That cost is confined to Read the Docs. `SPHINX_JOBS` defaults to `auto`, so local builds and the Buildkite doc build are untouched. Verified with `make -n`: the default still renders `-j auto`, the override renders `-j 2`, and because `RTDSPHINXOPTS` and `LINKCHECKOPTS` derive from the same variable, the override also reaches `linkcheck`, `rtd-build`, and `rtd-fallback`. That last part matters for when the incremental cache path in ray-project#64277 is re-enabled — the cap will apply there too without another change. ## Why 2 rather than 3 2 is the value with a measured peak and a clean `oom_kill 0`. 3 would cost less wall clock and is plausibly enough, but it hasn't been measured, and at 3 workers the expected headroom lands between the two figures above, closer to the margin that is already producing intermittent kills. Given the failure mode is timing-dependent rather than threshold-dependent, the point of the change is durable headroom rather than getting just back under a line. If the wall-clock cost proves painful, 3 is the obvious thing to measure next. ## Follow-up Read the Docs documents the memory limit as upgradable on Business. Raising it would let the parallelism come back and undo the wall-clock cost. That's a separate ask to Read the Docs rather than a change in this repo, and it's worth making regardless of this PR. ray-project#65631 is the measurement PR that produced the numbers above. It can be closed once this lands; the `SPHINX_JOBS` plumbing it carried is included here, and its diagnostic wrapper was always meant to come back out. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Douglas Strodtman <[email protected]>
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.
Why
The incremental RtD PR-preview build (added in #64277) isn't paying off, and a clean build is faster and lower-variance in practice. Opening as a draft for @ronny-anyscale to review, since this is your workstream.
Present-state evidence from read-only RtD build logs (project
anyscale-ray, 2026-07-08):3968 added= full rebuild. The discard reason has moved from[new config](the version-skew fixed by [ci][doc] Repair doc build cache production; skip incremental for structural PRs #64414/[doc] rtd: walk origin/master (not shallow HEAD) to find the doc cache #64482) to[config changed ('intersphinx_mapping')]/[config changed ('llms_txt_exclude')]— a config value that differs between the postmerge cache producer and the RtD build environment.What this changes
Collapses the
build.jobs.build.htmloverride so every build — PR previews and branch/tag builds alike — runs a full cleanmake -C doc html. Thertd/rtd-fallbackMakefile targets anddoc/load_doc_cache.pystay in the tree so the incremental path can be re-enabled later.Re-enable criteria (not in this PR)
N changedrather thanNNNN added— which needs the config-determinism gap closed (intersphinx_mapping,llms_txt_exclude, and any other env-signature config that differs between producer and RtD).The
post_checkoutskip guard (skip PR builds that don't touch doc-affecting files) is unchanged — it's orthogonal and still valuable.🤖 Generated with Claude Code