perf: configurable response compression#2271
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
avitenzer
reviewed
Apr 15, 2026
…ip over brotli The client-facing fiber compress middleware was the single largest CPU hog on the eth router after the passthrough and SendBytes fixes — 28% / 408s of a 900s window, dominated by fasthttp.nonblockingWriteBrotli. The Go brotli implementation (andybalholm/brotli) at LevelBestSpeed runs at ~60 MB/s/core versus gzip BestSpeed at ~150–200 MB/s/core, and the extra wire-size savings over gzip are marginal for typical JSON-RPC payloads. Introduce a --response-compression flag (values: gzip, brotli, off) threaded through ConsumerCmdFlags to both rpcconsumer and rpcsmartrouter. Default is gzip: the middleware still runs, but a tiny pre-middleware strips `br` from Accept-Encoding so fasthttp's encoder selects gzip. Ops can opt back into the old brotli behavior per-deployment, or disable compression entirely when the process is behind a compressing ingress. Covered by tests for the Accept-Encoding stripper (token-aware, q-value-aware, case-insensitive) and for each mode's observed Content-Encoding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d sizes Adds two helpers for evaluating the three response-compression modes (off, gzip, brotli) introduced in the previous commit: - BenchmarkResponseCompression exercises the full fiber middleware chain at small (~256B), medium (~16KB), and large (~1MB) JSON-RPC-shaped payloads. Huge buckets (128MB, 1GB) are gated behind LAVA_BENCH_HUGE=1 to avoid accidental multi-minute runs and large allocations on CI. - TestCompressionRatios prints an at-a-glance table of original vs encoded bytes and the savings percentage per (size, mode). Logs only; never fails. Both share a synthetic JSON-RPC generator so the numbers are reproducible. The generator docstring flags that the repeating zero-padded hex compresses better than real-world bodies, so ratios should be read as upper bounds while CPU throughput numbers remain representative. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6688c1e to
24eca2d
Compare
avitenzer
approved these changes
Apr 16, 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.
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changemainbranchReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...