Skip to content

feat(git): warm most-cloned repos in the background after startup#299

Draft
worstell wants to merge 2 commits into
mainfrom
feat/git-warm-cache-readiness
Draft

feat(git): warm most-cloned repos in the background after startup#299
worstell wants to merge 2 commits into
mainfrom
feat/git-warm-cache-readiness

Conversation

@worstell
Copy link
Copy Markdown
Contributor

@worstell worstell commented May 7, 2026

Adds prewarm-most-cloned-repos to the git strategy. When > 0, launches a background pass after startup that warms the top N repos (per the per-repo histogram, summed over the last 14 days) so subsequent requests for popular repos hit a warm local mirror. 0 (default) disables.

Does not gate Ready(). Cachew's snapshot/bundle/wire-protocol handlers already serve cold pods correctly via S3-cache and upstream-pass-through fallbacks; the prewarm pass is an optimization that reduces first-request latency for popular repos and accelerates when this pod begins contributing to S3 mirror-snapshot freshness, without making cold pods wait to join the LB.

Per-repo failures and an empty histogram are logged and otherwise ignored — this is an optimization, not a correctness invariant.

Includes a metadatadb fix: MemoryBackend.Query lazy-created the namespace under a read lock, racing with concurrent Apply on other namespaces.

@worstell worstell force-pushed the feat/git-warm-cache-readiness branch from 9839a22 to b0b0fb3 Compare May 7, 2026 23:32
@worstell worstell changed the title feat(git): gate readiness on warming top-N most-cloned repos feat(git): gate readiness on prewarming the most-cloned repos May 7, 2026
@worstell worstell force-pushed the feat/git-warm-cache-readiness branch from b0b0fb3 to 84b4d69 Compare May 7, 2026 23:34
@worstell worstell force-pushed the feat/git-warm-cache-readiness branch from 84b4d69 to 09acad1 Compare May 19, 2026 19:06
Query held RLock while m.ns() wrote to m.state on first access for a namespace, racing with concurrent Apply on other namespaces. Read the map directly; queryState handles a nil namespace map.
@worstell worstell force-pushed the feat/git-warm-cache-readiness branch from 09acad1 to fc8e253 Compare May 19, 2026 20:57
@worstell worstell changed the title feat(git): gate readiness on prewarming the most-cloned repos feat(git): warm most-cloned repos in the background after startup May 19, 2026
Adds prewarm-most-cloned-repos to the git strategy. When > 0, the strategy
launches a background pass after warmExistingRepos completes that warms that
many of the top repos (per the per-repo histogram, summed over the last
14 days) so subsequent requests for popular repos hit a warm local mirror.
0 (default) disables.

Does not gate Ready(). Cold-path fallbacks in the snapshot/bundle/wire-
protocol handlers already serve traffic correctly while warming runs, so
the pod can join the LB immediately. Per-repo failures and an empty
histogram are logged and otherwise ignored — this is an optimization, not
a correctness invariant.

Uses FetchTimeout (not CloneTimeout) on the fetch path so a slow upstream
on an already-cloned mirror cannot extend prewarm by an hour.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e4193-0c35-732e-96f0-b9c97aed2fae
@worstell worstell force-pushed the feat/git-warm-cache-readiness branch from fc8e253 to 1a1728f Compare May 19, 2026 20:59
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