Skip to content

chore(profiler): better compression testing and minor fixes#4697

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
felix.geisendoerfer/strengthen-gzip-compression-tests
Apr 29, 2026
Merged

chore(profiler): better compression testing and minor fixes#4697
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
felix.geisendoerfer/strengthen-gzip-compression-tests

Conversation

@felixge

@felixge felixge commented Apr 27, 2026

Copy link
Copy Markdown
Member

What does this PR do?

See commits.

Motivation

Follow-up cleanups to #4696 suggested by my clanker. Separate PR to make the main one easier to review.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

Unsure? Have a question? Request a review!

@felixge felixge changed the title chore: strengthen gzip compression tests test(profiler): verify gzip compression levels Apr 27, 2026
@felixge felixge changed the title test(profiler): verify gzip compression levels profiler: better compression testing and minor fixes Apr 27, 2026
@codecov

codecov Bot commented Apr 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.04%. Comparing base (997e8b2) to head (18fcb7c).

Additional details and impacted files
Files with missing lines Coverage Δ
profiler/compression.go 88.33% <100.00%> (ø)

... and 439 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 27, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 61.40% (+3.96%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 18fcb7c | Docs | Datadog PR Page | Give us feedback!

@felixge
felixge marked this pull request as ready for review April 27, 2026 07:19
@felixge
felixge requested a review from a team as a code owner April 27, 2026 07:19
@felixge felixge changed the title profiler: better compression testing and minor fixes chore(profiler): better compression testing and minor fixes Apr 27, 2026
@pr-commenter

pr-commenter Bot commented Apr 27, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-04-29 07:56:33

Comparing candidate commit 18fcb7c in PR branch felix.geisendoerfer/strengthen-gzip-compression-tests with baseline commit 997e8b2 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 224 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@nsrip-dd nsrip-dd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Confirmed the new tests fail if the fixes are reverted. I was gonna suggest b3f1228 as a followup to the parent PR so it's good to see it here.

gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Apr 29, 2026
### What does this PR do?

Adds a functional gzip compression mode for the profiler via `DD_PROFILING_DEBUG_COMPRESSION_SETTINGS=gzip`. This was already kinda working, but not really, hence the "fix" title.

- Defaults `gzip` to gzip-6, matching the gzip level legacy mode applies when it compresses profiler-produced profiles.
- Adds gzip-to-gzip recompression so gzip mode works for runtime profiles that are already gzip-compressed at gzip-1.
- Adds tests for gzip mode and gzip recompression.

See #4697 for some follow-up cleanups.

### Motivation

This is done for incident-53386, where zstd caused a memory usage increase. The gzip mode provides an alternative to the default zstd compression while keeping profiler uploads compressed.

### Reviewer's Checklist

- [x] Changed code has unit tests for its functionality at or near 100% coverage.
- [ ] [System-Tests](https://github.com/DataDog/system-tests/) covering this feature have been added and enabled with the va.b.c-dev version tag.
- [ ] There is a benchmark for any new code, or changes to existing code.
- [ ] If this interacts with the agent in a new way, a system test has been added.
- [ ] New code is free of linting errors. You can check this by running `make lint` locally.
- [x] New code doesn't break existing tests. You can check this by running `make test` locally.
- [ ] Add an appropriate team label so this PR gets put in the right place for the release notes.
- [ ] All generated files are up to date. You can check this by running `make generate` locally.
- [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running `make fix-modules` locally.

Tests run:

- `go test ./profiler -run 'TestNewCompressionPipeline|TestDebugCompressionEnv/explicit-gzip' -count=1`


Co-authored-by: felix.geisendoerfer <[email protected]>
Base automatically changed from felix.geisendoerfer/fix-profiler-support-gzip-compression-mode to main April 29, 2026 07:06
felixge added 4 commits April 29, 2026 09:17
Close gzip readers after io.Copy in the gzip recompression paths so any
final decompressor error state is observed. This applies to both
gzip->gzip and gzip->zstd recompression because both use a gzip reader
for the input stream.

This is not believed to fix any real issues, it's just done to follow
the proper life cycle.
Both recompressors decompress gzip input via an io.Pipe and forward the
decoded bytes to an output compressor; only the output type differed.
Collapse them into a single gzipDecodingRecompressor parameterized over
the compressor interface, which both *kgzip.Writer and *sharedZstdEncoder
already satisfy.
If kgzip.NewReader fails (e.g. on a corrupt or non-gzip stream) the
goroutine inside gzipDecodingRecompressor used to exit immediately,
leaving io.Pipe with no reader. Any in-flight or subsequent pw.Write
from the caller would then block forever, also preventing Close from
ever draining the error channel.

Close the read end of the pipe with the final error before sending it
on the err channel, so pending and future writes fail fast with that
error and the caller can complete normally.

Includes a regression test that runs inside a testing/synctest bubble
so the deadlock is detected deterministically rather than via a
wall-clock timeout: synctest.Wait returns once every goroutine in the
bubble is durably blocked or has exited, and the test then asserts
that Write actually returned with an error.
darccio pushed a commit that referenced this pull request May 4, 2026
### What does this PR do?

Adds a functional gzip compression mode for the profiler via `DD_PROFILING_DEBUG_COMPRESSION_SETTINGS=gzip`. This was already kinda working, but not really, hence the "fix" title.

- Defaults `gzip` to gzip-6, matching the gzip level legacy mode applies when it compresses profiler-produced profiles.
- Adds gzip-to-gzip recompression so gzip mode works for runtime profiles that are already gzip-compressed at gzip-1.
- Adds tests for gzip mode and gzip recompression.

See #4697 for some follow-up cleanups.

### Motivation

This is done for incident-53386, where zstd caused a memory usage increase. The gzip mode provides an alternative to the default zstd compression while keeping profiler uploads compressed.

### Reviewer's Checklist

- [x] Changed code has unit tests for its functionality at or near 100% coverage.
- [ ] [System-Tests](https://github.com/DataDog/system-tests/) covering this feature have been added and enabled with the va.b.c-dev version tag.
- [ ] There is a benchmark for any new code, or changes to existing code.
- [ ] If this interacts with the agent in a new way, a system test has been added.
- [ ] New code is free of linting errors. You can check this by running `make lint` locally.
- [x] New code doesn't break existing tests. You can check this by running `make test` locally.
- [ ] Add an appropriate team label so this PR gets put in the right place for the release notes.
- [ ] All generated files are up to date. You can check this by running `make generate` locally.
- [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running `make fix-modules` locally.

Tests run:

- `go test ./profiler -run 'TestNewCompressionPipeline|TestDebugCompressionEnv/explicit-gzip' -count=1`


Co-authored-by: felix.geisendoerfer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants