Repository navigation
fix: replace EncodeAll with streaming encoder in CDC chunk storage - #1065
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly optimizes memory usage in the CDC chunk storage by refactoring the ZSTD compression mechanism. It addresses a critical issue where the previous Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a significant memory leak by replacing EncodeAll with a streaming zstd encoder. The changes in both local.go and s3.go correctly adopt the NewPooledWriter for streaming compression, which should resolve the unbounded heap growth. All suggested code review comments were dropped as they contradicted the repository's rule to prioritize consistency with existing code patterns over adopting alternative patterns for readability.
a796f69 to
aa51bb5
Compare
EncodeAll allocates a fresh internal encoder (with a 128MB+ history buffer) on every call, regardless of the receiver object. This meant that even though the encoder was obtained from sync.Pool, the actual compression work was done by a new internally-allocated encoder each time — causing unbounded heap growth proportional to the number of chunks written (confirmed via pprof heap comparison: 363MB growth per batch before fix). Switch both local and S3 chunk stores to the streaming API: NewPooledWriter → Write → Close. This reuses the encoder's existing internal state across calls, which is what sync.Pool is designed for. Also add a dedicated pprof HTTP server behind the --pprof-addr flag (default disabled) to enable heap and goroutine profiling during live operation.
aa51bb5 to
09f3129
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1065 +/- ##
=====================================
Coverage 5.04% 5.04%
=====================================
Files 6 6
Lines 436 436
=====================================
Hits 22 22
Misses 410 410
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…1065) EncodeAll allocates a fresh internal encoder (with a 128MB+ history buffer) on every call, regardless of the receiver object. This meant that even though the encoder was obtained from sync.Pool, the actual compression work was done by a new internally-allocated encoder each time — causing unbounded heap growth proportional to the number of chunks written (confirmed via pprof heap comparison: 363MB growth per batch before fix). Switch both local and S3 chunk stores to the streaming API: NewPooledWriter → Write → Close. This reuses the encoder's existing internal state across calls, which is what sync.Pool is designed for. Also add a dedicated pprof HTTP server behind the --pprof-addr flag (default disabled) to enable heap and goroutine profiling during live operation. (cherry picked from commit 7620270)
|
Successfully created backport PR for |
…ackport #1065] (#1067) Bot-based backport to `release-0.9`, triggered by a label in #1065. EncodeAll allocates a fresh internal encoder (with a 128MB+ history buffer) on every call, regardless of the receiver object. This meant that even though the encoder was obtained from sync.Pool, the actual compression work was done by a new internally-allocated encoder each time — causing unbounded heap growth proportional to the number of chunks written (confirmed via pprof heap comparison: 363MB growth per batch before fix). Switch both local and S3 chunk stores to the streaming API: NewPooledWriter → Write → Close. This reuses the encoder's existing internal state across calls, which is what sync.Pool is designed for. Also add a dedicated pprof HTTP server behind the --pprof-addr flag (default disabled) to enable heap and goroutine profiling during live operation.
EncodeAll allocates a fresh internal encoder (with a 128MB+ history
buffer) on every call, regardless of the receiver object. This meant
that even though the encoder was obtained from sync.Pool, the actual
compression work was done by a new internally-allocated encoder each
time — causing unbounded heap growth proportional to the number of
chunks written (confirmed via pprof heap comparison: 363MB growth per
batch before fix).
Switch both local and S3 chunk stores to the streaming API:
NewPooledWriter → Write → Close. This reuses the encoder's existing
internal state across calls, which is what sync.Pool is designed for.
Also add a dedicated pprof HTTP server behind the --pprof-addr flag
(default disabled) to enable heap and goroutine profiling during
live operation.