Skip to content

storage-controller: reuse DatumVec when truncating status history#36991

Merged
antiguru merged 1 commit into
mainfrom
claude/modest-knuth-hd5c3n-2
Jun 11, 2026
Merged

storage-controller: reuse DatumVec when truncating status history#36991
antiguru merged 1 commit into
mainfrom
claude/modest-knuth-hd5c3n-2

Conversation

@antiguru

Copy link
Copy Markdown
Member

Motivation

The handle_row closure in partially_truncate_status_history decoded each snapshot row with Row::unpack, which allocates a fresh Vec<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 DatumVec and decodes rows via borrow_with, which returns its allocation to the vector on drop and reuses it across rows. extract_key/extract_time take &[Datum], and &DatumVecBorrow deref-coerces to &[Datum], so the call sites are unchanged. The closure was already mut/FnMut (it mutates latest_row_per_key), so capturing the DatumVec by value and borrowing it mutably is fine.

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog entry.

Generated by Claude Code

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.
@antiguru antiguru requested a review from a team as a code owner June 11, 2026 13:18
@antiguru antiguru requested a review from martykulma June 11, 2026 13:28

@martykulma martykulma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @antiguru !

@antiguru antiguru merged commit 5641743 into main Jun 11, 2026
117 checks passed
@antiguru antiguru deleted the claude/modest-knuth-hd5c3n-2 branch June 11, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants