fix: use memory friendly file split logic#2264
Merged
Racer159 merged 11 commits intozarf-dev:mainfrom Feb 7, 2024
Merged
Conversation
✅ Deploy Preview for zarf-docs canceled.
|
Noxsios
suggested changes
Jan 30, 2024
refactor: remove unnecessary else Co-authored-by: razzle <harry@razzle.cloud>
Racer159
suggested changes
Jan 31, 2024
Co-authored-by: Wayne Starr <Racer159@users.noreply.github.com>
8a78b18 to
017eb82
Compare
017eb82 to
d306aa7
Compare
Racer159
suggested changes
Feb 7, 2024
Contributor
Racer159
left a comment
There was a problem hiding this comment.
Sorry for the delay, one tiny change on the messaging but should be GTG after that
Noxsios
approved these changes
Feb 7, 2024
TristanHoladay
referenced
this pull request
in defenseunicorns/uds-core
Feb 15, 2024
[](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [defenseunicorns/zarf](https://github.com/defenseunicorns/zarf) | patch | `v0.32.2` -> `v0.32.3` | --- ### Release Notes <details> <summary>defenseunicorns/zarf (defenseunicorns/zarf)</summary> ### [`v0.32.3`](https://github.com/defenseunicorns/zarf/releases/tag/v0.32.3) [Compare Source](https://github.com/defenseunicorns/zarf/compare/v0.32.2...v0.32.3) ##### What's Changed ##### Fixes - Properly handle panic that could occur during checksum validation by [@​mjnagel](https://github.com/mjnagel) in [https://github.com/defenseunicorns/zarf/pull/2262](https://github.com/defenseunicorns/zarf/pull/2262) - Add the `--key` flag to the init cmd to properly allow for signed init packages by [@​dgershman](https://github.com/dgershman) in [https://github.com/defenseunicorns/zarf/pull/2259](https://github.com/defenseunicorns/zarf/pull/2259) - Restore destroy script functionality during `zarf destroy` by [@​Racer159](https://github.com/Racer159) in [https://github.com/defenseunicorns/zarf/pull/2274](https://github.com/defenseunicorns/zarf/pull/2274) - Fix symlink inclusion within component resources by [@​dgershman](https://github.com/dgershman) in [https://github.com/defenseunicorns/zarf/pull/2256](https://github.com/defenseunicorns/zarf/pull/2256) - Use memory friendly file split logic for partial packages by [@​daniel-palmer-gu](https://github.com/daniel-palmer-gu) in [https://github.com/defenseunicorns/zarf/pull/2264](https://github.com/defenseunicorns/zarf/pull/2264) - Fix reproducible tarball creation on Windows systems by [@​Noxsios](https://github.com/Noxsios) in [https://github.com/defenseunicorns/zarf/pull/2293](https://github.com/defenseunicorns/zarf/pull/2293) ##### Docs - Make branding more consistent and add community meetup references to docs by [@​Racer159](https://github.com/Racer159) in [https://github.com/defenseunicorns/zarf/pull/2258](https://github.com/defenseunicorns/zarf/pull/2258) ##### Dependencies - Update github.com/anchore/clio digest by [@​renovate](https://github.com/renovate) in [https://github.com/defenseunicorns/zarf/pull/2277](https://github.com/defenseunicorns/zarf/pull/2277) and [https://github.com/defenseunicorns/zarf/pull/2283](https://github.com/defenseunicorns/zarf/pull/2283) - Update all non-major dependencies (including Gitea v1.21.5, Syft v0.100.0, K9s v0.31.7 and Crane v0.19.0) by [@​renovate](https://github.com/renovate) in [https://github.com/defenseunicorns/zarf/pull/2187](https://github.com/defenseunicorns/zarf/pull/2187) ##### Development - Add a more robust chart search regexManager by [@​Racer159](https://github.com/Racer159) in [https://github.com/defenseunicorns/zarf/pull/2278](https://github.com/defenseunicorns/zarf/pull/2278) and [https://github.com/defenseunicorns/zarf/pull/2284](https://github.com/defenseunicorns/zarf/pull/2284) - Partial refactor of injector logic in `k8s`, and `cluster` packages by [@​chrishorton](https://github.com/chrishorton) in [https://github.com/defenseunicorns/zarf/pull/2271](https://github.com/defenseunicorns/zarf/pull/2271) ##### New Contributors - [@​daniel-palmer-gu](https://github.com/daniel-palmer-gu) made their first contribution in [https://github.com/defenseunicorns/zarf/pull/2264](https://github.com/defenseunicorns/zarf/pull/2264) **Full Changelog**: zarf-dev/zarf@v0.32.2...v0.32.3 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/defenseunicorns/uds-core). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNzMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjE3My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: TristanHoladay <40547442+TristanHoladay@users.noreply.github.com> Co-authored-by: Micah Nagel <micah.nagel@defenseunicorns.com>
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.
Description
When splitting a tarball using
--max-package-size, zarf will load the entire tarball into memory and copy it to new slices before writing the new files to disk resulting in memory usage up to 2x of the tarball. This can result in large memory usage when the package tarball is large itself.This PR updates the logic to read the original tarball in chunks of 16 MiB at a time thereby fixing the memory issue.
Testing
Will be breaking this down into a few sections:
Test setup
We will be reusing the
TestMultiPartPackagetest and updatingsrc\test\packages\05-multi-part\zarf.yamlto the following to test a larger package size and setting--max-package-size=500:We will expect the test to fail as the number of expected split files will no longer match the original test, however we will be able to see the memory usage while the test runs.
We will capture memory usage using
top | grep zarf.Test off of main
Before we look at the results from the code changes, lets first look at the results from main for comparison.
zarf-2024-01-27-23-31-37-3566031216.log
When the package tarball is being split, memory tops out at 2.1g
Test off of PR
zarf-2024-01-27-23-42-37-480658840.log
When the package tarball is being split, memory remains steady at under 250m
Related Issue
Fixes #2231
Type of change
Checklist before merging