fix: snapshot cli: reduce memory footprint#179
Merged
Christos Vontas (cv711) merged 15 commits intomainfrom Mar 5, 2026
Merged
fix: snapshot cli: reduce memory footprint#179Christos Vontas (cv711) merged 15 commits intomainfrom
Christos Vontas (cv711) merged 15 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors S3 backup/restore concurrency to reduce memory usage by introducing bounded worker pools for uploads/downloads, making worker counts explicit, and adding tests/benchmarks for the new helpers.
Changes:
- Introduce explicit worker-count constants and split upload/download concurrency across public/private buckets.
- Replace ad-hoc goroutine/semaphore logic with generic worker helpers (
runWorkers,runDownloadWorkers,runUploadWorkers) and improved progress reporting. - Add unit tests and benchmarks for the new upload/download worker helpers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/util/s3.go | Adds explicit upload worker constant, refactors bucket upload and downloader to use new generic worker helpers. |
| internal/snapshot/s3.go | Adds explicit download worker constant and uses it (split across buckets) during snapshot asset backup. |
| internal/util/s3_downloader_test.go | New tests/benchmarks for bounded download worker behavior and error handling. |
| internal/util/s3_uploader_test.go | New tests/benchmarks for bounded upload worker behavior and error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Kevin Rudde (kevinrudde)
approved these changes
Mar 5, 2026
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.
This pull request introduces several improvements and refactorings to the S3 backup and restore logic, focusing on concurrency handling, worker configuration, and error management. The main changes include refactoring the upload and download worker pools for S3 operations, improving error handling to avoid deadlocks, and adding comprehensive tests for the new download worker logic. Additionally, there are some minor fixes and improvements to command-line naming and logging.
S3 Worker Pool Refactoring and Concurrency Improvements:
uploadBucket) and download (DownloadBucket) logic to use configurable worker pools, improving performance and reliability for large-scale operations. This includes introducingtotalUploadWorkersandtotalDownloadWorkersconstants, and splitting worker allocation between public and private buckets. The new implementation uses generic worker pool functions (runWorkers,runUploadWorkers,runDownloadWorkers) to process files and objects concurrently, with improved cancellation and error propagation. [1] [2] [3] [4] [5] [6] [7] [8]internal/util/s3_downloader_test.go) covering the download worker pool implementation. Tests verify correct concurrency, error handling, and ensure no deadlocks occur if workers or producers fail. Benchmarks were also added to measure memory usage and performance for different worker counts.Error Handling and Logging Enhancements:
Miscellaneous Improvements and Fixes:
snpashot→snapshot) incmd/snapshot/snapshot.go.These changes collectively make the S3 backup and restore process more robust, scalable, and easier to maintain.