storage-controller: reuse DatumVec when truncating status history#36991
Merged
Conversation
The handle_row closure in partially_truncate_status_history decoded each snapshot row with Row::unpack, allocating a fresh Vec<Datum> per row in the hot truncation loop. Capture a re-used DatumVec in the closure and decode via borrow_with instead, which returns the allocation to the vector on drop and reuses it across rows.
martykulma
approved these changes
Jun 11, 2026
martykulma
left a comment
Contributor
There was a problem hiding this comment.
lgtm, thanks @antiguru !
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.
Motivation
The
handle_rowclosure inpartially_truncate_status_historydecoded each snapshot row withRow::unpack, which allocates a freshVec<Datum>on every call. This runs in the hot per-row truncation loop over the status history shard.This is a sibling change to the metrics-history truncation PR (#36990); same pattern, different call site.
Tips for reviewer
The closure now captures a re-used
DatumVecand decodes rows viaborrow_with, which returns its allocation to the vector on drop and reuses it across rows.extract_key/extract_timetake&[Datum], and&DatumVecBorrowderef-coerces to&[Datum], so the call sites are unchanged. The closure was alreadymut/FnMut(it mutateslatest_row_per_key), so capturing theDatumVecby value and borrowing it mutably is fine.Checklist
$T ⇔ Proto$Tmapping (possibly in a backwards-incompatible way), then it is tagged with aT-protolabel.Generated by Claude Code