perf: avoid per-chunk byte[] copy in CryptifyClient.StoreChunkAsync#30
Merged
Conversation
Use the ByteArrayContent(buffer, offset, count) overload to slice the source array without copying, instead of allocating a fresh byte[] per chunk and BlockCopy'ing into it. For a 100 MB upload at the 1 MB chunk size this avoids 100 redundant 1 MB allocations on top of the original buffer. Closes #27
Contributor
Author
|
RULES check: edited the PR body to drop two em-dashes flagged by the |
rubenhensen
approved these changes
May 28, 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.
Summary
StoreChunkAsyncwas allocating a freshbyte[]per chunk andBuffer.BlockCopy'ing the payload in, just to hand it off toByteArrayContent. For a 100 MB upload at the 1 MB chunk size that's 100 redundant 1 MB allocations on top of the original buffer.Switched to the
ByteArrayContent(byte[] buffer, int offset, int count)overload, which wraps the source slice in place (no copy). No call-site changes;UploadAsyncalready passes the source buffer plusoffset/end.Test plan
dotnet buildsucceeds on net8.0 and net10.0.dotnet test: 22/22 pass on net10.0 (existing suite doesn't coverCryptifyClient; this is a zero-behaviour-change perf tweak).Closes #27