Skip to content

[ci][doc] Log builder CPU and memory around the RtD Sphinx build - #65631

Closed
dstrodtman wants to merge 5 commits into
masterfrom
djs-260820-rtd-builder-resources
Closed

dstrodtman wants to merge 5 commits into
masterfrom
djs-260820-rtd-builder-resources

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Summary

Read the Docs builds intermittently fail with a bare EOFError raised from multiprocessing/connection.py, with no document named and no cause given:

Traceback
=========

      File ".../multiprocessing/connection.py", line 399, in _recv
        raise EOFError
    EOFError

make: *** [Makefile:91: html] Error 2

doc/Makefile builds with -j auto, so Sphinx forks one write worker per CPU. When a worker dies, the parent reports only that EOFError. This PR wraps the existing make invocation in the .readthedocs.yaml html job so the builder's CPU count, cgroup memory ceiling, peak memory, and cgroup OOM counters print around every build.

It's a measurement step, not a fix. Nothing about the build changes.

Why this isn't a content problem

  • The point in the write phase where it surfaces moves between builds: 58%, 78%, and 92% across three recent failures. A bad document would fail at the same place every time.
  • Five builds in the last two days failed with this signature, one of them on master. Every other RtD failure in that window is an ordinary fail_on_warning trip.
  • One PR hit it after passing an hour earlier on the same base commit, and other PRs built successfully in the same window.
Build When (UTC) Version Died at
4343286 Aug 20 21:52 PR preview 58%
4343129 Aug 20 21:11 PR preview 92%
4343048 Aug 20 20:59 PR preview —
4342961 Aug 20 20:35 PR preview —
4339216 Aug 20 03:41 master 78%

Why measure before capping -j

The likely mechanism is the kernel OOM-killing a write worker. Lowering -j is the obvious response, but choosing a value blind would cost wall-clock on every doc build and might buy nothing, since the useful cap depends on how many CPUs the builder actually has. If the builder has two CPUs, -j auto is already 2 and a cap isn't the answer at all. The cgroup memory.events OOM counters settle whether an OOM kill is even what's happening.

Implementation notes

  • The diagnostics run around the build rather than in a post_build job because post_build is skipped when the build fails, and the failing build is the one worth measuring.
  • rc carries make's exit status through to the job's exit, so a real Sphinx failure still fails the build. Verified under sh -e that the diagnostics run and the non-zero status propagates.
  • Every probe is guarded with || true or || echo, so a missing file or a non-matching grep can't abort the job under set -e.
  • The script avoids the constructs the RtD job runner is known to mishandle, per the existing comments in this file: no printf with escape sequences, no backslash escapes, and no shell comments inside the block.
  • Validated with sh -n and by parsing the YAML.

Follow-up

Once a few builds have reported their numbers, this wrapper comes back out along with whatever the real fix turns out to be.

Read the Docs builds have been failing with a bare EOFError raised from
multiprocessing/connection.py. The doc Makefile passes -j auto, so Sphinx
forks one write worker per CPU, and when a worker dies the parent reports
only that EOFError. The log names no document and no cause, and the point
in the write phase where it surfaces moves between builds: 58%, 78%, and
92% across three recent failures.

Five builds in the last two days failed this way, one of them on master,
so the cause is the builder rather than any single PR. Every other RtD
failure in that window is an ordinary fail_on_warning trip.

The likely mechanism is the kernel OOM-killing a write worker, but
confirming it needs numbers the build doesn't currently report: the
builder's CPU count, its cgroup memory ceiling, the peak the build
reached, and the cgroup OOM counters. Lowering -j without those would
slow every doc build and might buy nothing, since the useful cap depends
on how many CPUs the builder has.

Wrap the existing make invocation so those values print before and after
it. The diagnostics run around the build rather than in a post_build job
because post_build is skipped on failure, and the failing build is the
one worth measuring. rc carries make's exit status through, so a real
Sphinx failure still fails the build, and every probe is guarded so a
missing file or a non-matching grep can't abort the job.

This is a temporary measurement step. Remove the wrapper once the numbers
are in and the follow-up fix lands.

Signed-off-by: Douglas Strodtman <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request wraps the Sphinx build in .readthedocs.yaml with builder resource diagnostics to troubleshoot intermittent build failures, likely caused by OOM-killing of write workers. The feedback suggests adding clear labels to the printed metrics (such as CPU count and cgroup memory limits) to improve log readability and make troubleshooting easier.

Comment thread .readthedocs.yaml
Comment on lines +116 to +127
echo "=== builder capacity ==="
nproc || true
grep -E "MemTotal|MemAvailable" /proc/meminfo || true
cat /sys/fs/cgroup/memory.max 2>/dev/null || echo "no cgroup v2 memory.max"
cat /sys/fs/cgroup/memory.high 2>/dev/null || echo "no cgroup v2 memory.high"
rc=0
make -C doc html HTMLDIR="$READTHEDOCS_OUTPUT/html" || rc=$?
echo "=== builder peak, sphinx exit $rc ==="
cat /sys/fs/cgroup/memory.peak 2>/dev/null || echo "no cgroup v2 memory.peak"
cat /sys/fs/cgroup/memory.events 2>/dev/null || echo "no cgroup v2 memory.events"
grep -E "MemAvailable" /proc/meminfo || true
exit $rc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The printed values for nproc, memory.max, memory.high, and memory.peak are raw numbers without labels, which makes the build logs harder to interpret and troubleshoot. Adding clear labels to these metrics improves log readability and maintainability.

          echo "=== builder capacity ==="
          echo "CPUs: $(nproc 2>/dev/null || echo 'unknown')"
          grep -E "MemTotal|MemAvailable" /proc/meminfo || true
          if [ -r /sys/fs/cgroup/memory.max ]; then echo "memory.max: $(cat /sys/fs/cgroup/memory.max)"; else echo "memory.max: not found"; fi
          if [ -r /sys/fs/cgroup/memory.high ]; then echo "memory.high: $(cat /sys/fs/cgroup/memory.high)"; else echo "memory.high: not found"; fi
          rc=0
          make -C doc html HTMLDIR="$READTHEDOCS_OUTPUT/html" || rc=$?
          echo "=== builder peak, sphinx exit $rc ==="
          if [ -r /sys/fs/cgroup/memory.peak ]; then echo "memory.peak: $(cat /sys/fs/cgroup/memory.peak)"; else echo "memory.peak: not found"; fi
          cat /sys/fs/cgroup/memory.events 2>/dev/null || echo "no cgroup v2 memory.events"
          grep -E "MemAvailable" /proc/meminfo || true
          exit $rc

@dstrodtman

Copy link
Copy Markdown
Contributor Author

The first build with this wrapper reproduced the failure and answered the question. Build 4343347, RtD html job:

=== builder capacity ===
4                          <- nproc
MemTotal:        7961384 kB
MemAvailable:    6068508 kB
7130316800                 <- cgroup memory.max, about 6.6 GiB
max                        <- cgroup memory.high, unset

=== builder peak, sphinx exit 2 ===
6371254272                 <- cgroup memory.peak, about 5.9 GiB
low 0
high 0
max 0
oom 0
oom_kill 1                 <- a process in this cgroup was OOM-killed
oom_group_kill 0
MemAvailable:    6100020 kB

oom_kill 1 confirms the mechanism. The kernel killed a process in the build's cgroup, Sphinx lost a write worker, and the parent surfaced that as the bare EOFError. Peak sat about 760 MB under the ceiling, which is consistent with the kill landing on the allocation that would have crossed it.

The builder has 4 CPUs, so -j auto forks 4 write workers, each holding its own copy of the Sphinx environment, against a 6.6 GiB ceiling. That's the cost driver, and it explains why the reported document varies between builds: whichever worker happens to be holding the most when the ceiling is reached is the one that dies.

It also rules out the cheap non-answer. A cap is worth doing, because -j auto really is 4 here rather than 2.

Worth noting the ceiling is a per-build cgroup limit rather than host pressure, so this isn't contention from other builds on the same machine. The build simply asks for more than it's allowed.

Suggested follow-up, kept separate from this measurement PR: parameterize the job count in doc/Makefile as something like SPHINX_JOBS ?= auto, and set a lower value from .readthedocs.yaml only. That confines the reduced parallelism to the memory-capped RtD builder and leaves local builds and the Buildkite doc build on -j auto, so nothing outside RtD pays wall-clock for it.

@dstrodtman

Copy link
Copy Markdown
Contributor Author

Worth adding why this is new rather than long-standing, because it changes what the right fix is.

The RtD build didn't always use -j auto. Read the Docs' own Sphinx invocation adds -j auto only when the project carries the opt-in BUILD_IN_PARALLEL feature flag, per readthedocs/doc_builder/backends/sphinx.py:

if self.project.has_feature(Feature.BUILD_IN_PARALLEL):
    build_command.extend(["-j", "auto"])

That flag is off by default, so RtD was almost certainly building Ray's docs serially. #64277 pointed build.jobs.build.html at make -C doc html instead, and the Makefile has carried -j auto since well before that commit, because until then it was only used by the Buildkite doc build. So the RtD builder went from one write process to one per CPU. On this builder that's 4. #64599 then made every PR preview a full clean -a -E build rather than the incremental one, which removed the remaining relief on the preview path.

Neither PR was wrong. They just moved a 4x write-phase memory multiplier onto the one builder with a hard memory ceiling.

The ceiling is RtD's standard one, not something that changed under us. memory.max of 7,130,316,800 bytes is exactly the "7GB of memory" the platform documents for Business, so there's no sign of a vendor-side downgrade. Read the Docs documents that limit as upgradable.

What made it start failing in mid-August is growth crossing the line, not a single commit. First EOFError on master was build 4334194, Aug 19 06:00 UTC. master builds Aug 15 through Aug 18 all passed. It's been intermittent since rather than constant, and the failures at 06:00 and 08:23 on Aug 19 both predate #64977, which landed 22:43 UTC that day, so the intersphinx snapshot work isn't the trigger either. Peak at 5.9 GiB against a 6.64 GiB ceiling is what intermittent looks like: whichever worker holds the most when the ceiling is reached is the one that dies, which is also why the reported document moves between builds.

So there are two independent levers, and they aren't exclusive:

  1. Cap the job count on the RtD path only, via something like SPHINX_JOBS ?= auto in doc/Makefile set to a lower value from .readthedocs.yaml. This walks back the part of #64277 that the constrained builder can't afford, and leaves local builds and the Buildkite doc build on -j auto so nothing outside RtD pays wall-clock.
  2. Ask Read the Docs to raise the memory limit, which their docs list as upgradable on Business. This keeps the parallelism and the build time.

Given headroom is only about 760 MB and the docs keep growing, doing 1 now and pursuing 2 separately seems right, so the next content addition doesn't put us straight back here.

The first diagnostic build confirmed the OOM kill and gave a 4-CPU,
7 GB builder with a 5.9 GiB peak, but it left the worker count assumed
rather than measured.

Sphinx resolves -j auto through multiprocessing.cpu_count, which reports
the host's logical CPUs and is neither affinity- nor cgroup-aware. nproc
reports the affinity mask instead. If the two disagree, Sphinx forks more
write workers than the container has CPUs to run, each carrying its own
copy of the environment, and the peak is set by the larger number rather
than by the 4 that nproc reported.

That distinction also decides whether the abrupt mid-August onset has an
explanation. The lock file is fully hash-pinned and unchanged, and the
document count moved only from 4058 to 4087 between a passing build on
Aug 15 and a failing one on Aug 20, so neither dependencies nor content
growth account for it. A change in the host's CPU count would, and it is
not visible in any build metadata the API exposes.

Print all three counts so they can be compared rather than assumed.

Signed-off-by: Douglas Strodtman <[email protected]>
The python -c probe added in the previous commit came back mangled. The
job runner strips single quotes from arguments, so the quoted labels
became bare names: one printed the function object rather than its label
and the next raised NameError before its value was reported. The comment
block in this file already warned about that class of quirk.

It did answer the question it was added for before failing, reporting 4
where nproc also reported 4, so this builder isn't overcommitting write
workers. Keep measuring it per build anyway, since a host with a
different CPU count would change the answer, and the abrupt onset has no
other explanation on the Ray side: the lock file is hash-pinned and
unchanged, and the document count moved only 4058 to 4087 across the
window.

nproc and nproc --all give the same affinity-versus-installed comparison
without any quoting for the runner to strip.

Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman

Copy link
Copy Markdown
Contributor Author

Correcting part of my earlier comment. I attributed the mid-August onset to growth crossing the memory ceiling. That doesn't hold up, and two more builds since have narrowed things further.

Content growth isn't it. The Sphinx environment went from 4058 documents on a passing Aug 15 master build to 4087 on a failing Aug 20 one. A 0.7% change can't move a build from under a ceiling to over it.

Dependency drift isn't it either. doc/requirements-doc.lock.txt is fully hash-pinned and hasn't changed since before Aug 14, so the environment is identical across the window.

The builder isn't overcommitting workers. The concern behind the CPU probe was that Sphinx resolves -j auto through multiprocessing.cpu_count, which reports installed host CPUs rather than the affinity mask, so it could fork more workers than the container can run. On this builder both report 4, so that's not happening.

And my "onset Aug 19" claim was not statistically meaningful. The EOFError rate is roughly 5 in 200 builds. Across the ten or so master builds between Aug 15 and Aug 18 the expected count is about 0.25, so seeing none of them fail that way is exactly what you'd expect even if the rate had been identical for weeks. The API retains only about five days of build history and exposes no builder metadata, so I can't date the onset from build data at all.

What the two newest builds show is that this is marginal rather than threshold-crossing. Build 4343476 passed with memory.peak at 6,503,370,752 and oom_kill 0. The failing build 4343347 peaked lower, at 6,371,254,272, and was killed. So the kill isn't a simple case of the cumulative peak crossing the 7,130,316,800 limit. The build routinely runs within about 600 to 750 MB of the ceiling, and whether a given run survives depends on the timing of individual allocations across four workers.

What stands from the earlier comment is the structural part: #64277 moved the RtD build onto the Makefile's -j auto, and #64599 made previews full clean builds, which is what put four write workers and a thin margin on the one builder with a hard memory cap. What I can't support is naming a specific thing that tipped a rare failure into a visible cluster.

That doesn't change the remediation, and if anything it strengthens the case for capping the job count on the RtD path, since there's no threshold to get back under. It's the one lever that creates real headroom rather than restoring a margin that was never comfortable.

Parameterize the Sphinx job count as SPHINX_JOBS, defaulting to auto so
nothing changes for existing callers, and add a temporary paired
measurement to the Read the Docs html job.

The job count needs to come down on the memory-capped RtD builder, where
four write workers each carry their own copy of the environment against a
7 GB ceiling. Picking a value blind trades wall clock on every doc build
for headroom, so measure the trade first.

Between-build comparison cannot resolve it. The html job for the same
full clean build ranges from 368 to 562 seconds across recent master
builds, a spread far larger than the effect being measured. So the html
job runs the build twice within one job, once at the default and once at
SPHINX_JOBS=2, which cancels the between-builder variance. Epoch seconds
print around each arm, and memory.peak is reset between them where the
kernel allows, giving a per-arm peak as well as a per-arm duration.

Both arms are full clean builds, since SPHINXOPTS carries -a -E, so
neither reuses the other environment. The remaining confound is order,
because the second arm starts with a warm page cache, so a following run
reverses the arms.

The doubled job may approach the build time limit. The job exits on arm
A's status, so the published output and the pass or fail signal still
come from the default configuration.

The measurement wrapper comes back out before this merges. The
SPHINX_JOBS parameter stays, since the follow-up fix sets it from
.readthedocs.yaml.

Signed-off-by: Douglas Strodtman <[email protected]>
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core devprod labels Aug 21, 2026
The paired run answered the cost question and exposed a gap. On one
builder the same full clean build took 349 seconds at -j auto and 620
seconds at SPHINX_JOBS=2, so halving the job count costs about 78 percent
more wall clock. That is a lower bound, since the second arm ran with a
warm page cache, which favors it.

What the paired run could not measure is the saving that cost is meant to
buy. memory.peak turned out not to be resettable on this kernel, so the
reading taken after each arm was one high-water mark across both rather
than a figure per arm. Both reads returned the same value, which is
arm A's peak.

Drop to a single arm at SPHINX_JOBS=2 so memory.peak describes that
configuration alone. Peak memory is far more stable across builders than
duration, with three runs at -j auto landing within 180 MB of each other,
so one clean sample is worth more here than another paired comparison.

Signed-off-by: Douglas Strodtman <[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]>
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Aug 27, 2026
@dstrodtman

Copy link
Copy Markdown
Contributor Author

Closing as obsolete. This PR was the temporary diagnostic wrapper to measure builder CPU and peak memory around the RtD Sphinx build at -j auto vs a lower job count. Those numbers are captured, and the permanent follow-up has since landed on master in #65643, which sets SPHINX_JOBS=2 on the Read the Docs html job and records the measurements in the config comment. Resolving this branch against current master leaves no remaining diff, so there's nothing left to merge.

@dstrodtman dstrodtman closed this Aug 27, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core devprod docs An issue or change related to documentation go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants