perf: fetch pr blobs by blob sha#111
Merged
Merged
Conversation
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
Fetches PR file contents by blob SHA (
git/blobs/{sha}) instead of path+ref (contents/{path}?ref=), eliminating the erratic multi-second server-side stalls of the contents API that pushed semantic-diff first paint to ~10s on PR files pages.Motivation
Closes #110. Measured against the same endpoints: contents-by-path TTFB ranges 0.25–8.0s independent of file size (five of six identical requests at 0.25–0.6s, one at 4.9s), while blobs-by-SHA stays at 0.27–0.46s across all runs. With ~36 contents calls behind a 6-slot queue, a handful of stalled calls gated every file's render.
Changes
PrFilenow carries the blobshafrom the files API (head side; base side for removed files)GithubClient.getBlobRawfetches raw bytes by blob SHA;listBlobShasmaps path → blob SHA from one recursive tree callloadContextresolves base-side SHAs via a singlegit/trees/{mergeBase}?recursive=1call, in parallel with the guid index; rate limits propagate, other failures degrade to the contents fallbackfetchBlobaccepts an optional blob SHA (cache key folds with prefetch); a 404 on the SHA falls back to path+reffetchPair,buildGuidIndex, and base-sidemergeSourcesfetches all ride the SHA path; head-side source prefabs (not PR files) keep the contents fallbackTesting
pnpm test— 184 passed (12 new: blob-SHA pair/meta fetching, renamed/removed sides, truncated-tree and 404 fallbacks, rate-limit propagation)pnpm typecheck,pnpm lint,pnpm build— cleanpnpm e2e— 10 passed (extension loaded in Chromium)getBlobRaw is not a function, contents API still touched) before implementation