mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-28 21:15:33 +00:00
test: production-shaped push/pull benchmark with per-backend request counts
TestBenchRealImages pushes and pulls three images whose layer sizes are
copied from real manifests in the production appview database (the median,
p75 and p90 images by layer count) and reports, per operation, wall time and
the number of requests to the registry, the fake PDS, the hold and S3, broken
down by endpoint. Skipped unless BENCH_PROFILES is set, so the integration
target does not run it. BENCH_LAT_{PDS,HOLD,S3} inject per-request latency,
which is what makes byte-path changes visible in-process; request counts are
the reliable signal either way.
internal/reqcount counts and delays requests through a handler wrapper and a
client-side RoundTripper. testharness.WithBackendTap wraps the PDS and S3
handlers and puts a counting reverse proxy in front of the hold;
testpds.WithMiddleware is the hook that makes the PDS side possible.
The bench showed a pull costs three hold calls per blob, not two: distribution
installs its notifications listener unconditionally and it re-Stats every blob
after ServeBlob to build the pull event. The backlog's presign memoization
item is rewritten with the measured numbers.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WTdBxLFU5TpwmqVdVsN1wq
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
65db7945b2
commit
bf4e63e810
+23
-2
@@ -31,12 +31,29 @@ type Server struct {
|
||||
didHostEsc string // percent-encoded host:port for synthesized DIDs
|
||||
}
|
||||
|
||||
// Option configures a fake PDS.
|
||||
type Option func(*serverOptions)
|
||||
|
||||
type serverOptions struct {
|
||||
middleware func(http.Handler) http.Handler
|
||||
}
|
||||
|
||||
// WithMiddleware wraps the PDS's handler, for request counting or latency
|
||||
// injection in benchmarks.
|
||||
func WithMiddleware(mw func(http.Handler) http.Handler) Option {
|
||||
return func(o *serverOptions) { o.middleware = mw }
|
||||
}
|
||||
|
||||
// New starts a fake PDS bound to a random port via httptest.NewServer. The
|
||||
// server is torn down automatically via t.Cleanup. Callers should immediately
|
||||
// install s.Directory() with atproto.SetDirectory() so DID resolution short-
|
||||
// circuits through the in-memory store.
|
||||
func New(t *testing.T) *Server {
|
||||
func New(t *testing.T, opts ...Option) *Server {
|
||||
t.Helper()
|
||||
var o serverOptions
|
||||
for _, opt := range opts {
|
||||
opt(&o)
|
||||
}
|
||||
s := &Server{
|
||||
t: t,
|
||||
dir: newDirectory(),
|
||||
@@ -58,7 +75,11 @@ func New(t *testing.T) *Server {
|
||||
mux.HandleFunc("/xrpc/com.atproto.repo.uploadBlob", s.handleUploadBlob)
|
||||
mux.HandleFunc("/xrpc/com.atproto.sync.getBlob", s.handleSyncGetBlob)
|
||||
|
||||
s.httptest = httptest.NewServer(mux)
|
||||
var handler http.Handler = mux
|
||||
if o.middleware != nil {
|
||||
handler = o.middleware(handler)
|
||||
}
|
||||
s.httptest = httptest.NewServer(handler)
|
||||
t.Cleanup(s.httptest.Close)
|
||||
|
||||
s.didHostEsc = didWebForHost(strings.TrimPrefix(s.httptest.URL, "http://"))
|
||||
|
||||
Reference in New Issue
Block a user