Skip to content

[doc] rtd: walk origin/master (not shallow HEAD) to find the doc cache - #64482

Merged
elliot-barn merged 2 commits into
masterfrom
fix-load-doc-cache-origin-master
Jul 1, 2026
Merged

elliot-barn merged 2 commits into
masterfrom
fix-load-doc-cache-origin-master

Conversation

@ronny-anyscale

Copy link
Copy Markdown
Contributor

Description

Fixes the consumer side of the incremental Read the Docs build. find_latest_master_commit() never finds the doc cache, so every PR preview falls through to a full cold build — chronically near the RtD time limit, and timing out when the full build runs slow.

Root cause

find_latest_master_commit() (doc/load_doc_cache.py) ran git log with no ref — i.e. against HEAD. But Read the Docs checks out PRs with git clone --depth 1, so HEAD's history is grafted: the walk sees ~1 commit and never probes a real master commit. post_checkout deepens origin/master to 500 commits, but the consumer looked at HEAD, not origin/master — the two never meet. So load_doc_cache.py always raises No cache found for latest master commit, make rtd fails, and || make rtd-fallback does a full git clean + cold Sphinx build (~3,967 sources) on every build.

This is independent of the producer: even after #64414 repaired cache production (caches are flowing again — e.g. 0c1f570a8bf1, 5612883ea63f serve 200 today), the consumer still couldn't reach them. It also explains why merging master didn't help affected PRs — the shallow graft means git log HEAD never reaches a merged-in cached commit either.

Fix

Walk origin/master — the ref post_checkout already deepened — instead of HEAD. Falls back to HEAD when origin/master isn't available (e.g. a local checkout without that remote-tracking ref), and the existing || make rtd-fallback still covers a genuine cache miss.

Verified

Ran the modified find_latest_master_commit() against the live cache: it returns 0c1f570a8bf1 (a real cached master commit) where the old HEAD walk returned nothing usable. ruff + black clean.

Related issues

Consumer side of the incremental RtD build (#64277); producer repaired in #64414. Related to DOC-1047 (epic DOC-1046).

Additional information

Credit to the reviewer who pinpointed the shallow-HEAD / wrong-ref root cause. This is only fully exercised on a real RtD PR build (the --depth 1 clone + post_checkout deepen), so worth confirming on this PR's own preview that it logs Use build cache for commit … and an incremental N changed instead of 3967 added, 0 changed.

🤖 Generated with Claude Code

find_latest_master_commit() ran `git log` with no ref, i.e. against HEAD. But
Read the Docs checks out PRs with `git clone --depth 1`, so HEAD is grafted and
the walk sees ~1 commit -- it never probes a real master commit. post_checkout
deepens origin/master to 500 commits, but the consumer looked at HEAD, not
origin/master, so the two never meet. Result: load_doc_cache.py always raises
"No cache found", `make rtd` fails, and every PR preview falls through to a full
`git clean` + cold Sphinx build (~3,967 sources) -- chronically near the RtD
time limit, and timing out when the full build runs slow.

Walk origin/master -- the ref post_checkout already deepened -- instead. Fall
back to HEAD when origin/master is unavailable (e.g. a local checkout without
the remote-tracking ref); the `|| make rtd-fallback` clause still covers a
genuine cache miss.

This is the consumer side of the incremental RtD build (#64277); the producer
was repaired in #64414. Merging master did not help affected PRs because the
shallow graft means `git log HEAD` never reaches a merged-in cached commit.

Verified: the modified find_latest_master_commit() returns a live cached commit
(0c1f570...) against origin/master where the HEAD walk returned nothing.

Related to DOC-1047

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
@ronny-anyscale
ronny-anyscale requested a review from a team as a code owner July 1, 2026 18:34

@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 updates find_latest_master_commit in doc/load_doc_cache.py to fall back to HEAD if origin/master is unavailable, addressing issues with shallow clones on Read the Docs. The reviewer suggested using subprocess.run to check for the ref's existence, which simplifies the logic and avoids a try-except block.

Comment thread doc/load_doc_cache.py Resolved
Address review (@gemini-code-assist, endorsed by @dstrodtman): replace the
try/except check_output with subprocess.run(...).returncode == 0 so the ref
check no longer uses an exception for control flow.

Related to DOC-1047

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[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 labels Jul 1, 2026
@ronny-anyscale ronny-anyscale added the go add ONLY when ready to merge, run all tests label Jul 1, 2026
@elliot-barn
elliot-barn merged commit ea2c581 into master Jul 1, 2026
6 checks passed
@elliot-barn
elliot-barn deleted the fix-load-doc-cache-origin-master branch July 1, 2026 20:52
edoakes pushed a commit that referenced this pull request Jul 8, 2026
…4599)

## 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):

- 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 #64414/#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]>
elliot-barn pushed a commit that referenced this pull request Jul 9, 2026
#64482)

## Description

Fixes the **consumer** side of the incremental Read the Docs build.
`find_latest_master_commit()` never finds the doc cache, so every PR
preview falls through to a full cold build — chronically near the RtD
time limit, and timing out when the full build runs slow.

### Root cause

`find_latest_master_commit()` (`doc/load_doc_cache.py`) ran `git log`
with **no ref** — i.e. against `HEAD`. But Read the Docs checks out PRs
with `git clone --depth 1`, so `HEAD`'s history is grafted: the walk
sees ~1 commit and never probes a real master commit. `post_checkout`
deepens `origin/master` to 500 commits, but the consumer looked at
`HEAD`, not `origin/master` — the two never meet. So `load_doc_cache.py`
always raises `No cache found for latest master commit`, `make rtd`
fails, and `|| make rtd-fallback` does a full `git clean` + cold Sphinx
build (~3,967 sources) on every build.

This is independent of the producer: even after #64414 repaired cache
production (caches are flowing again — e.g. `0c1f570a8bf1`,
`5612883ea63f` serve 200 today), the consumer still couldn't reach them.
It also explains why *merging master didn't help* affected PRs — the
shallow graft means `git log HEAD` never reaches a merged-in cached
commit either.

### Fix

Walk `origin/master` — the ref `post_checkout` already deepened —
instead of `HEAD`. Falls back to `HEAD` when `origin/master` isn't
available (e.g. a local checkout without that remote-tracking ref), and
the existing `|| make rtd-fallback` still covers a genuine cache miss.

### Verified

Ran the modified `find_latest_master_commit()` against the live cache:
it returns `0c1f570a8bf1` (a real cached master commit) where the old
`HEAD` walk returned nothing usable. `ruff` + `black` clean.

## Related issues

Consumer side of the incremental RtD build (**#64277**); producer
repaired in **#64414**. Related to
**[DOC-1047](https://anyscale1.atlassian.net/browse/DOC-1047)** (epic
DOC-1046).

## Additional information

Credit to the reviewer who pinpointed the shallow-`HEAD` / wrong-ref
root cause. This is only fully exercised on a real RtD PR build (the
`--depth 1` clone + `post_checkout` deepen), so worth confirming on this
PR's own preview that it logs `Use build cache for commit …` and an
incremental `N changed` instead of `3967 added, 0 changed`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Ronny Roland <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
ray-project#64482)

## Description

Fixes the **consumer** side of the incremental Read the Docs build.
`find_latest_master_commit()` never finds the doc cache, so every PR
preview falls through to a full cold build — chronically near the RtD
time limit, and timing out when the full build runs slow.

### Root cause

`find_latest_master_commit()` (`doc/load_doc_cache.py`) ran `git log`
with **no ref** — i.e. against `HEAD`. But Read the Docs checks out PRs
with `git clone --depth 1`, so `HEAD`'s history is grafted: the walk
sees ~1 commit and never probes a real master commit. `post_checkout`
deepens `origin/master` to 500 commits, but the consumer looked at
`HEAD`, not `origin/master` — the two never meet. So `load_doc_cache.py`
always raises `No cache found for latest master commit`, `make rtd`
fails, and `|| make rtd-fallback` does a full `git clean` + cold Sphinx
build (~3,967 sources) on every build.

This is independent of the producer: even after ray-project#64414 repaired cache
production (caches are flowing again — e.g. `0c1f570a8bf1`,
`5612883ea63f` serve 200 today), the consumer still couldn't reach them.
It also explains why *merging master didn't help* affected PRs — the
shallow graft means `git log HEAD` never reaches a merged-in cached
commit either.

### Fix

Walk `origin/master` — the ref `post_checkout` already deepened —
instead of `HEAD`. Falls back to `HEAD` when `origin/master` isn't
available (e.g. a local checkout without that remote-tracking ref), and
the existing `|| make rtd-fallback` still covers a genuine cache miss.

### Verified

Ran the modified `find_latest_master_commit()` against the live cache:
it returns `0c1f570a8bf1` (a real cached master commit) where the old
`HEAD` walk returned nothing usable. `ruff` + `black` clean.

## Related issues

Consumer side of the incremental RtD build (**ray-project#64277**); producer
repaired in **ray-project#64414**. Related to
**[DOC-1047](https://anyscale1.atlassian.net/browse/DOC-1047)** (epic
DOC-1046).

## Additional information

Credit to the reviewer who pinpointed the shallow-`HEAD` / wrong-ref
root cause. This is only fully exercised on a real RtD PR build (the
`--depth 1` clone + `post_checkout` deepen), so worth confirming on this
PR's own preview that it logs `Use build cache for commit …` and an
incremental `N changed` instead of `3967 added, 0 changed`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Ronny Roland <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: 400Ping <[email protected]>
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]>
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 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.

3 participants