Skip to content

perf(github): read blobs through GraphQL in batches of fifty - #184

Merged
sweepies merged 2 commits into
mainfrom
perf/graphql-blobs
Nov 4, 2026
Merged

sweepies merged 2 commits into
mainfrom
perf/graphql-blobs

Conversation

@sweepies

@sweepies sweepies commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Finding #3 from the speed survey. A cold scan fetched every selected file with its own REST request; grafana-sized repositories select hundreds.

  • Client::blobs(repo, shas): cached blobs (via perf(github): serve Git blobs by SHA from the cache without revalidating #183's immutable cache) need no request; the rest go through GraphQL, fifty object(oid:) lookups per query, run concurrently.
  • A GraphQL text counts only when its Git blob SHA equals the one asked for, so a binary, truncated or re-encoded answer can never be taken for the blob. Those come through REST.
  • GraphQL results are cached as their REST representation, so later reads are free whichever way they came.
  • A failed GraphQL query falls back to REST for its batch.

Tests: the GitHub client test covers a verified text, a mismatched text and a binary blob (one GraphQL query, two REST reads), and a second read with no requests. The engine and CLI fakes now answer blob batches; the replay-based fixtures fall back to REST.

View guided diff Turn on auto-fix

A cold scan fetched every selected file with its own REST request.
`Client::blobs` serves cached blobs without a request and reads the rest
fifty to a GraphQL query, taking a GraphQL text only when it hashes to the
SHA asked for; binary, truncated or mismatched blobs come through REST.
GraphQL blobs are cached as their REST representation, so warm reads stay
free either way.
… a refused credential

- Only forty-hex SHAs go to GraphQL, which refuses a whole query for one
  malformed ID; others go straight to REST.
- A 401 or 403 from GraphQL stops the read. Refusals, limits, transport
  failures and fixtures without the batch fall back to REST.
- Cached blobs are looked up concurrently, and the engine's single-blob
  read goes through the same batch.
- Tests cover batches past fifty, an errors payload and a refused
  credential.
@sweepies
sweepies merged commit 17fc52c into main Nov 4, 2026
11 checks passed
@sweepies
sweepies deleted the perf/graphql-blobs branch November 4, 2026 14:58
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