Repository navigation
perf: accelerate backend gzip decoding with zlib-ng - #580
Merged
Merged
Conversation
deniszh
approved these changes
Oct 21, 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.
Why
Backend gzip inflation consumes about 20–30% of CPU in live profiles and about 43% on a large wildcard request. Faster decoding reduces request cost and tail latency without changing metric evaluation.
Architecture
The existing streaming backend reader uses zlib-ng 2.3.3 through its native
zng_*API. The default Make build downloads a commit-pinned, SHA-256-verified source archive, runs the library's tests, and links a private static archive. Runtime CPU dispatch remains enabled.This extends the fork's existing native decoder; system zlib lacks the measured decode performance. Separate symbols keep Cairo/libpng on system zlib and leave response compression unchanged. There is no preload shim or system-library replacement. The fork-specific integration can be removed if the common backend reader adopts an equivalent implementation.
Before / after
Usage
make buildactivates the dependency in the existing native build. The existingCARBONAPI_STREAM_RENDER=1andCARBONAPI_NATIVE_GZIP=1flags select this reader. No new runtime knob is introduced.make build TAGS='-tags cairo,nativegzip'builds the system-zlib alternative;make nocairouses the portable Go path. The README documents prerequisites, checksum pinning and cache cleanup. Docker andmake testexercise the default integration; the latter also checks both decoder fallbacks.Validation
make test, both fallback tests and golangci-lint 2.14.0 passed locally.The earlier live trial is evidence for a partial improvement, not proof that this PR fixes the six-VM regression. Rare worst-case latency and sustained fleet peak load remain unvalidated. GitHub CI passed on oldstable, stable and tip; CodeQL also passed.
Rollback / risk
Restore the previous binary or build without
zlibng. Existing startup flags can select Go decoding. First native builds now require downloading and compiling the pinned dependency; subsequent builds reuse.build/zlib-ng. No memory-reduction claim is made.