Repository navigation
storage: reduce manifest verification latency - #4906
Merged
milosgajdos merged 1 commit intoNov 11, 2026
Merged
Conversation
Signed-off-by: Perfloop Agent <[email protected]>
perfloop-agent
force-pushed
the
perfloop-pr-open-2s4z8mcfgb
branch
from
July 9, 2026 16:23
adcdd26 to
4d4b624
Compare
milosgajdos
approved these changes
Jul 18, 2026
|
@milosgajdos thanks for approving this back in July. Is there anything else you need from me to get it merged? |
milosgajdos
approved these changes
Nov 11, 2026
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.
Reduce Manifest Verification Latency
Headline Win
verifyManifest_latency(Primary Win): baseline128,746,104ns/op -> candidate21,460,250.5ns/op,-83.3313%reduction (n=10, p-value =1.08251e-05, significant), validated/won. No behavior change.verifyManifest_oci_latency(Improved Guardrail / Held Guardrail): baseline128,014,403ns/op -> candidate21,378,921ns/op,-83.2996%reduction (n=10, p-value =1.08251e-05, significant), outcome held as a guardrail.These figures are measured against a synthetic storage driver injecting 10ms of latency per operation to model a remote object-storage backend (detailed under "Performance Comparison" below). The mechanism is a sum-to-max transformation of independent I/O-bound checks, so the absolute reduction scales with per-check backend latency and the number of manifest references; a fast local backend sees a proportionally smaller gain.
Why It Matters
The
verifyManifestmethod validates each descriptor referenced by a manifest (including both Schema 2 and OCI manifest handlers) in a sequential loop. It performs independent, I/O-bound storage existence checks (usingmanifestService.ExistsandblobsService.Stat) for each layer or manifest.Step Independence Proof from Source Code
An inspection of the source code confirms that the individual descriptor existence checks are completely independent:
mnfst.References().Because these checks are completely independent and block on downstream storage I/O, serial execution causes the total verification latency to scale linearly with the number of references ($O(N) \times \text{latency of a single check}$ ). By overlapping these checks, we reduce latency from the sum of the check durations to the maximum of those durations, significantly improving manifest put performance.
Error Handling Semantics
Error-handling semantics are preserved. Each goroutine collects its descriptor's validation/existence errors into a per-index slot of a preallocated slice and always returns
nilto theerrgroup, so no check's failure cancels the group: every reference is checked to completion, and all errors are aggregated in the original reference order and returned together, exactly as the sequential loop did. The group context ends only when the caller's context does. The behavioral difference is concurrency itself: up toDefaultManifestVerificationConcurrencyLimitexistence checks run against the storage driver at once, where the sequential loop issued one at a time.Reproduction Recipe
Environment
Commits
472c9d38c9fc523599f37ca3207279e5ab10f74ff22306aa031576335b75b6a8d396003cdb2fd2c2Verification Benchmarks
The benchmarks used to measure performance were newly authored by the agent to ensure clean, cache-independent testing. To reproduce these results using standard Go tools, run the following benchmark commands:
Docker Schema 2 Manifest Verification Benchmark:
OCI Manifest Verification Benchmark:
Performance Comparison
verifyManifest_latencyverifyManifest_oci_latencyThe candidate latency of ~21ms is mathematically double the simulated 10ms driver latency because the
manifestService.Putoperation consists of two sequential phases:verifyManifestexecutes all descriptor presence checks in parallel (takingms.blobStore.Put, which incurs an additional sequential 10ms driverStatcheck.This validates the sum-to-max transformation.
Correctness & Quality Gates
All of the following correctness checks passed successfully (and no other suites were claimed):
pairingenvironment_consistentbaseline_validbenchmark_passedBuild Check(using commandgo build ./registry/storage/...)Concurrency & Race Check(using commandgo test -race -v ./registry/storage/... -run "TestVerifyManifest")Format Check(using commandgo fmt ./registry/storage/...)measurements_sanemetric_presentsample_sufficiencysample_independenceThe Change
We implemented race-free parallel manifest verification for both Docker Schema 2 and OCI manifest handlers:
verifyManifestmethod in bothschema2ManifestHandler(registry/storage/schema2manifesthandler.go) andocischemaManifestHandler(registry/storage/ocimanifesthandler.go) to process referenced descriptors concurrently usinggolang.org/x/sync/errgroup.DefaultManifestVerificationConcurrencyLimit = 16inregistry/storage/registry.goto decouple verification concurrency fromGOMAXPROCS, preventing downstream network/storage resource exhaustion.Touched Files
registry/storage/registry.goregistry/storage/schema2manifesthandler.goregistry/storage/ocimanifesthandler.goregistry/storage/ocimanifesthandler_benchmark_test.go(newly added OCI verification benchmark)Tried and Ruled Out (Alternatives)
cand_dftjcmdstj(commit615209bab6fbf7d244f240faa955a6d3bc308bce): This candidate was inconclusive because its ns/op samples were byte-identical across all 10 baseline/candidate runs due to Go test caching (the verifier failedsample_independencechecks). This candidate successfully parallelized the loops usingerrgroup.WithContext, but lacked cache-independent bench testing.Limits & Real-World Validation Target
Full Proof
The complete performance proof is available at:
https://app.perfloop.ai/t/oss/case_zptzacr9b7
This is an automated, human-reviewed Perfloop contribution opened by perfloop-agent. The body links to reproducible proof for the change. The change was benchmarked on perfloop/distribution, an automation fork of distribution/distribution; the commit on this PR's head branch carries the proof.
Assisted-by: PerfloopAgent:gemini-3.5-flash