Repository navigation
perf(storage): reuse pooled buffer for streamed puts - #241
Merged
Merged
Conversation
Greptile SummaryThe PR changes oversized streamed local puts to retain a reader-only pipe remainder so FileManager's pooled buffer performs the copy, while preserving WriterTo for byte-backed unary puts.
Confidence Score: 5/5The PR appears safe to merge, with no concrete correctness, security, or repository-rule issue identified. The changed reader composition preserves payload order and error handling for the reachable pipe-backed and byte-backed inputs, while the payload-copy extraction remains behaviorally equivalent to the previous implementation. Important Files Changed
Reviews (1): Last reviewed commit: "perf: preserve streamed copy write bound..." | Re-trigger Greptile |
Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]>
perfloop
Bot
force-pushed
the
perfloop-pr-open-hr4wx04w3p
branch
from
August 24, 2026 17:48
e70e0bc to
47a66bb
Compare
ovaistariq
approved these changes
Aug 28, 2026
|
🎉 This PR is included in version 1.12.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Local streamed Puts that cross the inline threshold join the consumed prefix to an
io.PipeReader.io.MultiReadercan selectWriteToand bypass FileManager's pooled copy buffer. Keep pipe-backed remainders reader-only so the existing buffer drives the copy.The change
joinPrefixserves the prefix before the remainder. It preserves the directWriterTopath for byte-backed unary Puts, so that path does not take the streamed copy behavior. The pipe-backed path still writes the prefix and remainder in order.Move raw-file payload copying and checksum calculation into a helper used by FileManager. Add coverage for prefix ordering, short writes, checksums, payload readback, and the local streamed Put path. The new benchmark covers threshold-sized, 1 MiB, and raw-file sync-boundary inputs.
This update replays the two commits on current main with matching DCO sign-offs; the source patch is unchanged.
Verification
make fmt-checkmake vetBenchmarkCacheServicePutLocalStreamFirstWriteWorkload:
four-worker first-write local streamed CacheService.Put allocation series with one Go execution thread, 100,000 fixed 64 KiB threshold-plus-two PutsB/opGenerated by Perfloop. Measurements and checks.
Note
Medium Risk
Changes the large-object Put I/O path in storage and file writes; behavior is intentionally split between streamed and byte-backed readers, with tests and benchmarks but still on a performance-critical hot path.
Overview
Streamed Puts that spill past the inline threshold no longer use
io.MultiReaderto stitch the peeked prefix to the rest of the body.joinPrefixserves the prefix first and only exposesio.WriterTowhen the remainder already implements it (e.g. unarybytes.NewReaderputs), so pipe-backed local streams stay reader-only andFileManager’scopyRawFilePayload1 MiB pooled buffer drives the remainder copy instead of an extra scratch allocation path.Raw-file streaming and CRC32 checksum logic move into
copyRawFilePayloadinstorage/files/payload.go, withFileManager.Writecalling that helper. Tests cover prefix ordering,WriterTopreservation, short writes, and checksums;TestStorage_PutGetDelete_LargeObjectasserts the direct-write path forWriterToinputs.BenchmarkCacheServicePutLocalStreamFirstWritemeasures concurrent first-write local streamed puts (threshold-sized, 1 MiB, and sync-boundary sizes) including allocation and live-heap metrics.Reviewed by Cursor Bugbot for commit 47a66bb. Bugbot is set up for automated code reviews on this repo. Configure here.