Slice stored .conda zip members instead of copying - #44
Merged
Merged
Conversation
Real .conda packages store their .tar.zst members uncompressed, so DataOffset locates the payload inside the outer bytes and a slice returns it with no io.ReadAll copy or buffer growth. Non-Store or out-of-range members fall back to Open+ReadAll. The stored path skips archive/zip's CRC32; the inner zstd frame check still catches corruption.
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.
readCondaMemberread each.tar.zstmember withio.ReadAll(io.LimitReader(rc, ...)), which grows a buffer by doubling and copies the whole member. Real.condapackages store their members uncompressed (zip.Store), sof.DataOffset()locates the payload inside the outer archive bytes andraw[off : off+CompressedSize64]returns it directly. Bounds are checked against a header that lies about size or offset; non-Storemembers and out-of-range headers fall through to the existingOpen+ReadAllpath.The stored path skips
archive/zip's CRC32 check on the member; the inner zstd frame check still catches corruption.Adds
TestCondaDeflatedMemberFallbackfor the non-Storepath andBenchmarkOpenConda(8 MiB incompressible pkg member so the stored.tar.zstis ~8 MiB). Interleaved benchstat, arm64 darwin, n=10, 2s each:The ~16 MiB B/op saving is roughly 2× the member size (
io.ReadAllgrowth doubles at the last step). Real conda packages run to hundreds of MB per member, so the saving scales with that.