- 
        Couldn't load subscription status. 
- Fork 485
refactor(profiler): alternative zstd encoder reuse approach #4078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(profiler): alternative zstd encoder reuse approach #4078
Conversation
This benchmark seems to have been broken since it was added in #3555.
| BenchmarksBenchmark execution time: 2025-10-28 09:34:28 Comparing candidate commit 1079a3d in PR branch  Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics. | 
e6f96f4    to
    4c9cf96      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the zstd encoder sharing mechanism by replacing a global mutex-based approach with a builder pattern that assigns acquire/release semantics to the compressor interface's Reset/Close methods.
Key Changes:
- Introduced compressionPipelineBuilderto manage shared zstd encoders per compression level
- Replaced global compressionMuxwith per-encoder semaphores embedded insharedZstdEncoder
- Updated all compression usage sites to call Close()afterReset()to properly release encoder resources
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description | 
|---|---|
| profiler/compression.go | Implements new compressionPipelineBuilderandsharedZstdEncodertypes with semaphore-based encoder sharing | 
| profiler/profiler.go | Uses compressionPipelineBuilderinstance to build compression pipelines | 
| profiler/profile.go | Removes global mutex locking and adds deferred Close()calls for resource release | 
| profiler/compression_test.go | Updates tests to use new builder pattern | 
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
59d5391    to
    280fb17      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor. Thanks!
What does this PR do?
Refactor the zstd encoder sharing implemented in #4058 by assigning acquire/release semantics to the compressor interface Reset / Close methods.
Motivation
Hide the implementation details of the shared encoder from the profile type implementations. Also properly support multiple zstd levels for different profile types. This is not needed for now, but the current interfaces expect this ability to work. If we want to constrain this in the future, we should do it on the interface level first.
Reviewer's Checklist
./scripts/lint.shlocally.Unsure? Have a question? Request a review!