Skip to content

Collect idle and obsolete shared ThinLTO caches - #164

Open
charliermarsh wants to merge 1 commit into
charlie/codex-defer-dev-depsfrom
codex/thinlto-build-cache-gc
Open

charliermarsh wants to merge 1 commit into
charlie/codex-defer-dev-depsfrom
codex/thinlto-build-cache-gc

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

cargo +ohm gc now reclaims individual shared ThinLTO backend objects after one hour without compiler use, and entire obsolete contexts immediately after an Ohm upgrade or compiler replacement. Cleanup remains manual, respects active consumers, and leaves cargo clean scoped to the current workspace.

We place shared ThinLTO objects under the existing compiler context and reuse its SQLite provenance and consumer lease. Rustc already refreshes object modification times on cache hits, so this adds no database tables, rows, or warm-build timestamp updates. Compatible worktrees continue to share backend objects. Recognized old flat ThinLTO namespaces are immediately eligible as legacy data; they are not imported into the new layout. If provenance cannot be recorded, new optional state stays private.

Shared ThinLTO caches no longer scan or prune at build completion. Explicit GC selects idle objects outside build locks, revalidates them under the existing locks, and retires bounded batches with the same 10 ms retirement budget. It also collects abandoned temporary entries and coordinates with the old automatic pruner. Unknown records, symlinks, active consumers, and dry-run semantics retain their existing protections.

The focused checks pass 38 GC unit tests, six ThinLTO management tests, and 18 command tests, plus Clippy. Full CI passes, including Cargo tests and Clippy on Linux and macOS, workspace tests, resolver tests, schemas, and formatting. Coverage includes expiry within an active context, refreshed objects, immediate upgrade cleanup, legacy caches, active leases, interruption and resumption, file and byte counts, compiler path selection, and warm builds after eviction. The local default Ohm compiler predates the backend cache feature, so the compiler-path integration uses an adapter; this verifies Cargo’s compiler-path and cleanup integration.

Warm-build measurements against #161 used isolated roots and balanced run order. On the 11-variant workload, 180 runs per binary measured 53.51 ms before and 53.30 ms after (paired -0.16%, 95% interval -1.98% to +0.67%). With 10,000 synthetic ThinLTO objects and a compiler adapter, 100 fresh release builds per binary measured 53.46 ms before and 53.57 ms after (paired -0.08%, 95% interval -3.00% to +1.98%). Neither comparison establishes a regression, and all 560 timed builds stayed fresh. Sampled warm invocations left the database and WAL unchanged. Fully fresh builds already skipped the old pruner; removing the end-of-build scan benefits builds that invoke the backend. The synthetic fixture measures Cargo bookkeeping, not LLVM cache-hit performance.

The 10,000-object cleanup fixture reclaimed all 10.4 MiB of idle objects while preserving a fresh object. It took 2 invocations totaling 16.8 seconds under the existing 10-second per-root collection limit, and a final dry run reported zero eligible files.

@charliermarsh
charliermarsh force-pushed the codex/thinlto-build-cache-gc branch from fec4973 to 35477e3 Compare October 17, 2026 01:25
@charliermarsh
charliermarsh changed the base branch from codex/per-dependency-build-cache-gc to charlie/codex-defer-dev-deps October 17, 2026 01:25
@charliermarsh
charliermarsh added this pull request to stack #163 October 17, 2026 01:25
charliermarsh added a commit to astral-experiments/ohm that referenced this pull request Oct 17, 2026
Prepare Ohm 1.99.0-5 with the check-to-build query-feed fix in astral-experiments/ohm-rust#187 and manual collection of shared ThinLTO caches in astral-experiments/ohm-cargo#164. The compiler's Cargo gitlink matches the manifest's Cargo revision.

The manifest, source revisions, manifest history, and formatting checks pass. The optimizations guide is updated separately in #151 for review.
@charliermarsh
charliermarsh force-pushed the codex/thinlto-build-cache-gc branch from 35477e3 to 78f286e Compare October 17, 2026 12:44
@charliermarsh
charliermarsh removed this pull request from stack #163 October 17, 2026 12:54
@charliermarsh
charliermarsh added this pull request to stack #166 October 17, 2026 12:54
charliermarsh added a commit to astral-experiments/ohm that referenced this pull request Oct 17, 2026
Update the Cargo pin in the unpublished Ohm 1.99.0-5 manifest to include the retained-native-archive support in astral-experiments/ohm-cargo#161 and the rebased ThinLTO cleanup change in astral-experiments/ohm-cargo#164. Align the compiler's Cargo gitlink with the manifest.

The source revisions, manifest history, and formatting checks pass.
@charliermarsh
charliermarsh force-pushed the codex/thinlto-build-cache-gc branch 4 times, most recently from e723256 to c034241 Compare October 17, 2026 15:52
@charliermarsh
charliermarsh removed this pull request from stack #166 October 23, 2026 16:31
@charliermarsh
charliermarsh added this pull request to stack #227 October 23, 2026 16:32
@charliermarsh
charliermarsh removed this pull request from stack #227 October 25, 2026 13:06
@charliermarsh
charliermarsh added this pull request to stack #241 October 25, 2026 13:06
@charliermarsh
charliermarsh removed this pull request from stack #241 October 27, 2026 02:57
@charliermarsh
charliermarsh added this pull request to stack #252 October 27, 2026 02:57
@charliermarsh
charliermarsh removed this pull request from stack #252 October 27, 2026 15:06
@charliermarsh
charliermarsh added this pull request to stack #255 October 27, 2026 15:06
@charliermarsh
charliermarsh removed this pull request from stack #255 October 27, 2026 21:36
@charliermarsh
charliermarsh added this pull request to stack #257 October 27, 2026 21:36
@charliermarsh
charliermarsh removed this pull request from stack #257 October 28, 2026 00:23
@charliermarsh
charliermarsh added this pull request to stack #259 October 28, 2026 00:23
@charliermarsh
charliermarsh removed this pull request from stack #259 October 28, 2026 17:21
@charliermarsh
charliermarsh added this pull request to stack #272 October 28, 2026 17:21
@charliermarsh
charliermarsh removed this pull request from stack #272 October 28, 2026 17:42
@charliermarsh
charliermarsh added this pull request to stack #273 October 28, 2026 17:42
@charliermarsh
charliermarsh removed this pull request from stack #273 October 29, 2026 04:52
@charliermarsh
charliermarsh added this pull request to stack #278 October 29, 2026 04:53
@charliermarsh
charliermarsh removed this pull request from stack #278 October 29, 2026 14:06
@charliermarsh
charliermarsh added this pull request to stack #290 October 29, 2026 14:06
@charliermarsh
charliermarsh removed this pull request from stack #290 October 30, 2026 02:25
@charliermarsh
charliermarsh added this pull request to stack #295 October 30, 2026 02:25
@charliermarsh
charliermarsh removed this pull request from stack #295 October 31, 2026 13:06
@charliermarsh
charliermarsh added this pull request to stack #329 October 31, 2026 13:07
@charliermarsh
charliermarsh removed this pull request from stack #329 October 31, 2026 18:02
@charliermarsh
charliermarsh added this pull request to stack #331 October 31, 2026 18:02
@charliermarsh
charliermarsh removed this pull request from stack #331 November 1, 2026 01:58
@charliermarsh
charliermarsh added this pull request to stack #364 November 1, 2026 01:58
@charliermarsh
charliermarsh removed this pull request from stack #364 November 1, 2026 11:41
@charliermarsh
charliermarsh added this pull request to stack #383 November 1, 2026 11:41
@charliermarsh
charliermarsh removed this pull request from stack #383 November 1, 2026 18:29
@charliermarsh
charliermarsh force-pushed the codex/thinlto-build-cache-gc branch from c034241 to e61146b Compare November 17, 2026 06:26
@charliermarsh
charliermarsh added this pull request to stack #542 November 17, 2026 06:29
@charliermarsh
charliermarsh force-pushed the codex/thinlto-build-cache-gc branch from e61146b to 44fe865 Compare November 17, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant