PackReader.read(): return a memoryview of the in-memory pack instead of copying - #10037
Merged
ThomasWaldmann merged 1 commit intoAug 4, 2026
Merged
Conversation
…of copying Avoids a per-chunk memcpy out of the cached pack; parse()/parse_meta() accept the memoryview.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10037 +/- ##
=======================================
Coverage 86.15% 86.15%
=======================================
Files 96 96
Lines 17360 17360
Branches 2659 2659
=======================================
Hits 14956 14956
Misses 1664 1664
Partials 740 740 ☔ View full report in Codecov by Harness. |
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
PackReader.read()read chunks from the in-memory pack by slicingpack_contents, abytesobject, so every read allocated and copied. It now returns amemoryviewslice, which is a view into the pack with no copy. On a profiled 6 GiB extract that copy cost about 1.3% of extract CPU.Supporting changes:
parse()andparse_meta()takebytesormemoryviewforcdata(both wrap it inmemoryview()anyway).get(read_data=False)returns header plus meta asbytes.The store range-read path is unchanged and still returns
bytes. Re-put and key detection already accept the buffer protocol.fixes #10030
Checklist
master