feat: optional gzip compression for ingest#18
Merged
Merged
Conversation
Add SetGzip(true) to opt into gzip-compressing the NDJSON ingest body. When enabled, each batch is compressed and sent with a Content-Encoding: gzip header; the endpoint must accept gzip-encoded ingest. Off by default, so existing behavior is unchanged. The gzip writer is per-worker and reused across flushes via Reset to avoid reallocating the compressor on every batch. Compression happens after the empty-body check and before request construction, so the 413 auto-reduce/chunking path compresses each chunk independently. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Adds opt-in gzip compression for the ingest path (review item #5 from the earlier performance pass). NDJSON is highly compressible, so for log-shaped workloads this trades a little CPU for a large reduction in wire bytes and latency.
SetGzip(true)enables it. Off by default — existing behavior is unchanged.Content-Encoding: gzip. The Quickwit endpoint must accept gzip-encoded ingest requests.Reset, so the compressor isn't reallocated per batch — matching how the JSON encoder/buffer are already reused.bytes.Readerstill lets net/http setContent-Length(compressed size).Test plan
TestIngest_GzipCompressesBody: server requiresContent-Encoding: gzip, decompresses, and asserts every record is delivered in order. (If the header were missing the server 400s, so the test genuinely exercises the encoding path.)go vet ./...cleango test ./...andgo test -race ./...passNotes
🤖 Generated with Claude Code