Repository navigation
perf(datasource): cut cold Docker Hub and GHCR round trips - #411
Merged
Merged
Conversation
sweepies
marked this pull request as draft
November 24, 2026 08:45
sweepies
marked this pull request as ready for review
November 24, 2026 09:08
- Docker Hub tags/list starts at n=50000, so even 28k-tag repositories list in one request; every other registry keeps n=1000 and Link paging. - Anonymous reads on registry-1.docker.io and ghcr.io mint their pull token from the known token service before the first read, under the scope's lock, instead of after a 401. A read the cache answers mints nothing; a failed mint fails the read; a rejected token still falls back to the challenge. The 401 path and the preemptive one share one mint helper (realm trust, credentials, expiry, persistence). - The four cosign .att/.sbom HEADs are sent at once and taken in the sequential order, with the same error precedence. - Current pinned-image SBOM reads overlap the lookup and digest stages; the image stage reads only the new digests and fallback platforms. - The recorder drops a token answer's issued_at so replays do not see every recorded token as expired; cassettes lose their now-unsent 401s. - Derived and state versions bumped for the touched sources.
… to registry endpoints
sweepies
force-pushed
the
perf/cold-docker-lookups
branch
from
November 24, 2026 19:11
1d939a1 to
fbc53d2
Compare
Merged
This branch was successfully deployed
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.
Part 4 of the performance series: fewer round trips for cold Docker/OCI lookups.
Changes
tags/list?n=50000(docker.rstags_url). Onlyregistry-1.docker.iostarts withn=50000; every other host keepsn=1000(GHCR defaults to 100, ECR Public returns 405 onn=10000, Quay caps at 100).Link: rel="next"is still followed. Measured live:grafana/lokigoes from 29 pages (~26 s) to 1 request (~2 s).registry-1.docker.io(auth.docker.io/token) andghcr.io(ghcr.io/token), so a cold image no longer costs a 401 round trip.minthelper:realm_trust, credential selection, token parsing,issued_at/Age/expires_inexpiry, and SQLite persistence (anonymous tokens only).token.lock(), so concurrent reads of one image share a single token.Cached::registry_freshchecks the cache first, using the sameprepare/freshlogicget_representationnow uses, so a warm digest read never mints a token..att/.sbomHEADs sent in parallel (join_all). Results are still processed in the old order (child.att, index.att, child.sbom, index.sbom): the first SBOM found wins, and an error ahead of it fails the read, as before.engine/src/lookup.rs). The key set (current_sbom_reads) comes from the sameneeds.sboms, digest andimagePlatformsrules onceplan_lookupshas run, and is always a subset of whatread_imageswould read. The image phase then reads only the new digests and fallback platforms. A key read without revalidation is read again if a retried dependency wants it fresh.Tests and fixtures
only_docker_hub_asks_for_every_tag_in_one_page(unit).cold_docker_hub_and_ghcr_reads_mint_one_token_before_the_first_read: one token for two concurrent reads; a Docker HubmirrorOfentry changes nothing.a_read_the_cache_answers_mints_no_token.a_failed_token_before_the_first_read_fails_the_read.cosign_tags_are_asked_about_at_once_and_taken_in_order: precedence, error ordering, and at least 4 HEADs in flight at once.n=1000URLs ton=50000. Replay ignores order, so nothing else had to change.issued_at, which made every replayed token already expired, so each read minted again. The recorder (testkit::undate_token) now dropsissued_atfrom token answers, and the existing cassettes had it removed the same way.registry.example. Token-flow tests stay on GHCR and Docker Hub and include the new token request.oci-config-notes,oci-tags,anonymous-registry-pull-token2→3;image-platform,sbom-os5→6; stateosv-advisory7→8,catalog,catalog-controls28→29,changelog15→16. This invalidates those cache entries once after upgrade.Verification (boat VM)
cargo test --workspace --locked --no-fail-fast -- --skip lockfiles::tests::real_: all green. The last change after that run was test-only;registry_protocolwas re-run, 37 passed.mise run fixtures:check: 57 cassettes, no possible secrets.cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo fmt --all --check: clean.Docs updated:
internals/cache.md(registry pull tokens),internals/image-sboms.md,guide/sources.md.Follow-ups