Lower ASGI gzip compresslevel from 9 to 4#3735
Draft
anth-volk wants to merge 1 commit into
Draft
Conversation
Stage 2 warm-parity measurement found /us/metadata p95 at 13.2s on Cloud Run vs 4.3s on App Engine. The ~70MB raw payload is compressed in-request by GZipMiddleware at starlette's default level 9 on Cloud Run, while App Engine's nginx sidecar gzips natively. Measured on the real payload: level 9 = 5.5s -> 9.0MB, level 4 = 0.7s -> 9.9MB, a 7.5x compression speedup for ~10% larger output (~0.2s extra transfer). Fixes #3734 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3735 +/- ##
=======================================
Coverage 79.82% 79.82%
=======================================
Files 70 70
Lines 4336 4336
Branches 808 808
=======================================
Hits 3461 3461
Misses 655 655
Partials 220 220 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #3734
Summary
Stage 2 of the Cloud Run cutover failed its warm-parity gate at 3.25× (limit 1.20×), localized entirely to
/us/metadata: p95 13.2 s on Cloud Run vs 4.3 s on App Engine, while liveness/readiness are faster on Cloud Run. The ~70 MB raw metadata payload is gzipped in-request by starlette'sGZipMiddlewareat its defaultcompresslevel=9on Cloud Run; App Engine flex never pays this cost because its nginx sidecar handles gzip natively at a low level.Change
One line in
asgi_factory.py: explicitcompresslevel=4.Measured on the actual production metadata payload (70.8 MB):
7.5× faster compression for ~10% larger output (~0.2 s extra transfer at typical bandwidth vs ~5 s of CPU saved per request).
Verification
tests/unit/test_asgi_factory.py: 15/15 pass; ruff clean.capture_migration_baseline.py --repetitions 10both platforms) — gate is CR p95 ≤ GAE p95 × 1.20.Out of scope per maintainer: the 70 MB payload itself (metadata slimming planned separately) and the
Accept-Encoding: identity500 (Cloud Run ~32 MB response cap; single known consumer always sends gzip; mooted by slimming).🤖 Generated with Claude Code