Repository navigation
[SVLS-8713] perf(logs-agent): compress log batches before waiting for the API key - #195
Draft
litianningdatadog wants to merge 1 commit into
Conversation
This was referenced Oct 21, 2026
litianningdatadog
force-pushed
the
tianning.li/logs-sc-4-compress-once
branch
from
October 21, 2026 19:50
947fde3 to
89ab609
Compare
litianningdatadog
force-pushed
the
tianning.li/logs-sc-5-compress-before-key
branch
from
October 21, 2026 19:50
6e0ef18 to
3fad977
Compare
Why: with an API key resolver, the flusher waited for the key and only then compressed the batches. The first key lookup can be slow (for example the first Secrets Manager call after a Lambda cold start, about 70-110 ms), so compression time was added on top of it. Measured on Lambda with bottlecap, this made the first flush after a cold start about 20 ms (11-13%) slower than bottlecap's own flusher, which compressed first. Warm flushes were not affected because the key is cached. What: each flush now compresses its batches first (only if some endpoint uses compression), then waits for the key, then sends. Compression can now overlap a key lookup that is already in flight, for example one started by another flusher that shares the key source. The requests and bytes sent do not change, and each batch is still compressed at most once. New tests check that every batch is compressed before the key is requested and not compressed again, that an additional endpoint alone triggers the early compression, and that nothing is compressed when no endpoint wants it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
litianningdatadog
force-pushed
the
tianning.li/logs-sc-5-compress-before-key
branch
from
October 21, 2026 19:52
3fad977 to
cff2697
Compare
litianningdatadog
force-pushed
the
tianning.li/logs-sc-4-compress-once
branch
from
October 21, 2026 19:52
89ab609 to
84cb56d
Compare
This branch has not been deployed
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.
What does this PR do?
flush()now compresses its batches first (only if some endpoint uses compression), then awaits the API key resolver, then sends. Same requests and bytes; each batch is still compressed at most once.Motivation
Part of SVLS-8713: bottlecap (the Datadog Lambda Extension) is replacing its own logs aggregator and flusher with this crate. Two rules for the whole stack:
Found by a real Lambda A/B test of bottlecap with this stack vs
main: the first flush after a cold start was about 20 ms (11–13%) slower. That flush waits for the first API key lookup (a Secrets Manager call, 70–110 ms), and the shared flusher compressed only after it, while bottlecap's old flusher compressed first so the work overlapped. With compression disabled on both sides the gap disappeared, confirming the cause. Warm flushes weren't affected (the key is cached).Additional Notes
After this change the same Lambda test showed parity: first-flush time −3.9% [95% CI −7.8%, +2.7%] over 40 cold starts, and warm, 128 MB, high-volume, all flush strategies and failing-intake runs all within noise vs
mainand vs the v101 release. A#[cfg(test)]thread-local counter incompress_zstdlets the tests check the ordering deterministically (no cost in release builds).Describe how to test/QA your changes
114 tests pass (new: every batch compressed before the key is requested and not again; extras-only compression; nothing compressed when no endpoint wants it; each mutation-checked). Workspace clippy, FIPS clippy and
cargo check -p datadog-serverless-compatclean.Stack
Each PR is nested under the PR it builds on (and targets). Review and merge from the top down.
serverless-components (
datadog-logs-agentoptions; merge first)maindefault/fipsfeaturesretry()+FlushPolicydatadog-lambda-extension (bottlecap)
main🤖 Generated with Claude Code