Repository navigation
perf(storage): reuse pooled buffer in recompaction writes - #245
Conversation
Greptile SummaryThe PR reduces recompaction-copy allocations by forcing non-
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "refactor(segment): hide the file's Reade..." | Re-trigger Greptile |
2a5fbcc to
2b036b0
Compare
|
Addressed in The repair keeps the recompaction copy-path change intact and adds the eviction state-transition guard, so the E2E protection assertion cannot accept an unsettled cleaner state. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1460517. Configure here.
1460517 to
5719bad
Compare
|
Addressed in The repaired test guard now retries the second order-key batch and avoids requiring a transient full-key listing, while preserving the existing LRU/FIFO survivor assertions. |
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
… the copy loop io.CopyBuffer only ignores buf because *os.File implements io.ReaderFrom; wrapping the destination in a plain io.Writer makes CopyBuffer use the pooled buffer, so the explicit copy loop is not needed. Also drops the unrelated eviction e2e script edits, which main fixed separately. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra Signed-off-by: Ovais Tariq <ot@tigrisdata.com>
5719bad to
10706e8
Compare
|
Rebased onto main and simplified ( |
|
🎉 This PR is included in version 1.14.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

The change
Segment.WriteEntrykeeps the sourceio.WriterTofast path and uses the acquired pooled buffer for readers without it. This prevents the destination file'sReaderFromfallback from allocating another copy buffer forSectionReaderinputs used by recompaction, while retaining the segment lock, rollback, short-write handling, byte-count validation, and accounting updates.The eviction protection check now retries the second batch of order-key writes and marks setup inconclusive if any write fails. Its wait no longer requires one
ocachecli listcall to observe all 30 keys before checking the settled LRU/FIFO survivor set.Testing
make test-storage TESTRUN='WriteEntry\|TestSegmentRecompaction_WithFragmentation\|TestSegmentRecompaction_IncompletePassKeepsOldSegment'make test-e2e-evictionmake lintmake fmt-checkmake license-checkWorkload:
ordinary timer-driven recompaction of two fragmented segments with 768 live 256 KiB entries at the supported default one-minute interval, with allocation as the outcome metricrecompaction-gc-alloc-bytes/opWorkload:
synchronous 64 KiB SectionReader payload copied through Segment.WriteEntry to an *os.File destination, repeated 10000 timesallocs/opB/opChecks: 6 passed.
Generated by Perfloop. Measurements and checks.
Note
Medium Risk
Changes the segment write hot path for non-WriterTo readers; behavior is guarded by new tests and benchmarks but affects all SectionReader/rate-limited compaction copies.
Overview
Segment.WriteEntrynow splits payload copy behavior by reader type: sources that implementio.WriterTo(e.g.*os.File) still copy directly to the segment file with the existing pooled 64 KiB buffer; readers without it (notablyio.SectionReaderduring recompaction) copy through a plainio.Writerwrapper soio.CopyBufferdoes not take the destination file’sReaderFrompath and allocate an extra ~32 KiB buffer per call.Benchmark and test coverage adds Linux timer-driven recompaction loop benchmarks (1 ms and production intervals, with optional CPU/GC/allocation metrics), factors
startRecompactionBenchmarkto accept a configurable interval, and addsTestManager_WriteEntrySectionReaderplus a micro-benchmark for 64 KiBSectionReaderwrites.Reviewed by Cursor Bugbot for commit 10706e8. Bugbot is set up for automated code reviews on this repo. Configure here.