perf(delta-upgrade): lazy chain walk, GHCR retry, parallel I/O, offline cache#360
Merged
perf(delta-upgrade): lazy chain walk, GHCR retry, parallel I/O, offline cache#360
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 101 passed | Total: 101 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 82.68%. Project has 3649 uncovered lines. Files with missing lines (5)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 81.61% 81.51% -0.1%
==========================================
Files 127 128 +1
Lines 19177 19736 +559
Branches 0 0 —
==========================================
+ Hits 15651 16087 +436
- Misses 3526 3649 +123
- Partials 0 0 —Generated by Codecov Action |
85309f1 to
fa6085f
Compare
fa6085f to
29eee29
Compare
29ea02c to
e845ba5
Compare
60cf42f to
af8de8c
Compare
af8de8c to
282aceb
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
…ne cache Four performance optimizations for the delta upgrade system: ## Lazy chain resolution (replaces eager graph build) Replace buildNightlyPatchGraph + walkNightlyChain with a lazy approach in resolveNightlyChain: - List all patch tags (1 HTTP call, kept) - Filter tags to only those between currentVersion and targetVersion using Bun.semver.order() — since patches are sequential, this gives the exact chain without fetching any manifests - Sort filtered tags by version - Fetch only the 1-2 manifests in the chain (instead of all N) This reduces manifest fetches from ~14 to 1-2 for typical upgrades. ## Retry with timeout for GHCR requests Add fetchWithRetry helper in ghcr.ts: - 10s timeout per request (AbortSignal.timeout) - 1 retry on transient errors (timeout, network, connection reset) - Applied to getAnonymousToken, fetchManifest, fetchTagPage - downloadNightlyBlob gets 30s timeout (no retry — large downloads) ## Parallel I/O fetchManifest(targetTag) and listTags() run concurrently via Promise.all after token acquisition — both only depend on the token, not each other. ## Patch pre-fetch for offline upgrades New file-based cache in ~/.sentry/patch-cache/ enables fully offline delta upgrades for both nightly and stable channels: - Background version check now pre-fetches delta patches (~50-80KB) after discovering a new version - Patches accumulate across runs: skip 3 versions, all 3 patches are cached, multi-hop upgrade is fully offline - resolveStableDelta/resolveNightlyDelta check cache before network - delta.source span attribute tracks cache vs network for telemetry - 7-day TTL with opportunistic cleanup during version checks - Two-pass cleanup preserves shared patches referenced by live chains
282aceb to
582d093
Compare
5 tasks
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.
Summary
Four performance optimizations for the delta upgrade system, addressing the 5-30s latency identified via telemetry in PR #355. Applies to both nightly and stable channels.
Before
buildNightlyPatchGraphfetches ALL ~14 patch manifests from GHCR in parallel (N HTTP calls)fetchManifest(targetTag)andlistTags()run sequentially despite no data dependencyAfter
fetchManifest(targetTag)andlistTags()run concurrently viaPromise.allafter token acquisition~/.sentry/patch-cache/. Subsequentsentry cli upgradeapplies patches offline with zero network calls. Patches accumulate across version check runs for multi-hop offline upgrades.Expected impact
build-patch-graphphasefetch-target-manifest+list-tagsChanges
Core optimizations:
src/lib/delta-upgrade.ts— ReplacebuildNightlyPatchGraph+walkNightlyChainwithfilterAndSortChainTags(pure function). AddpreloadedTagsfor parallelization. Cache-first path inresolveStableDelta/resolveNightlyDelta. NewprefetchNightlyPatchesandprefetchStablePatcheswith abort signal support.src/lib/ghcr.ts—fetchWithRetryhelper with 10s timeout + 1 retry for transient errors.New module:
src/lib/patch-cache.ts— File-based cache:savePatchesToCache,loadCachedChain(stitches patches from multiple runs),cleanupPatchCache(7-day TTL). Version-based naming is channel-agnostic.Integration:
src/lib/version-check.ts— After storing latest version, callsmaybePrefetchPatches()to download patches in background. Opportunistic cache cleanup.Telemetry:
delta.sourcespan attribute:"cache"vs"network"chain.tags_total,chain.tags_filtered,chain.fetched_countTests:
test/lib/patch-cache.test.ts— 23 tests: save/load/cleanup with edge cases (cross-run stitching, corrupt metadata, missing files, nightly versions)test/lib/delta-upgrade.test.tsandtest/isolated/delta-upgrade.test.ts