Repository navigation
perf: skip inline payload decode in DeleteKey and key listing - #208
Merged
Merged
Conversation
Greptile SummaryThis PR avoids copying inline payload data when deleting keys or listing key names.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "perf: skip inline payload decode in Dele..." | Re-trigger Greptile |
Base automatically changed from
fix/size-accounting-skip-payload-decode
to
main
August 14, 2026 17:58
DeleteKey and ListKeysWithPagination both fully proto.Unmarshal each
metadata row but never read ValueMessage.Data — DeleteKey uses only the
control fields (type, length, backing paths) for size accounting and file
reclamation, and the listing scan reads only expiry to drop expired rows.
Each therefore copies the inline Data payload (up to the 64 KiB inline
threshold) for nothing, on every delete and on every scanned key.
Extend the wire-extractor helpers:
- valueMessageExpiry reads expiry (field 3) off the wire, so the listing
loop no longer allocates a ValueMessage per scanned row at all.
- unmarshalValueMessageSkippingData rebuilds the message wire without the
Data field and defers to the generated decoder for the remaining small
fields, so DeleteKey keeps exact proto semantics (and stageFileDeletion's
*ValueMessage signature) while dropping the payload copy.
Both preserve the callers' prior behavior on a malformed row: DeleteKey
skips accounting/cleanup (as it did on a proto.Unmarshal error), and the
listing loop treats the row as non-expired and includes the key.
A differential test cross-checks both helpers against proto.Unmarshal (all
fields except Data for the delete path; expiry across shapes), plus a
malformed-input case. make test-storage passes.
Surfaced by Perfloop cases case_1mzwqcjjvr and case_527g56fg8z.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra
Signed-off-by: Ovais Tariq <[email protected]>
ovaistariq
force-pushed
the
fix/delete-list-skip-payload-decode
branch
from
August 14, 2026 18:00
1c8bd05 to
01b18a0
Compare
Contributor
Author
|
🎉 This PR is included in version 1.10.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.
Problem
Two more read paths fully
proto.Unmarshaleach metadata row but never readValueMessage.Data:DeleteKey(storage/storage.go) — uses only the control fields (ValueType,ValueLength,RawFilePath,SegmentPath) for size accounting and file reclamation viastageFileDeletion.ListKeysWithPagination— reads onlyExpiryto skip expired rows; it returns keys only.Each copies the inline
Datapayload (up to the 64 KiB inline threshold) for nothing — on every delete, and on every scanned key during a key listing.Fix
Extend the
value_wire.goextractors from #207 (varint core factored out):valueMessageExpiryreadsexpiry(field 3) off the wire → the listing loop no longer allocates aValueMessageper scanned row at all.unmarshalValueMessageSkippingDatarebuilds the message wire without field 2 (Data) and defers to the generated decoder for the remaining small fields. This keeps exact proto semantics andstageFileDeletion's*pb.ValueMessagesignature, while dropping the payload copy. (Raw-file/segment rows carry noData, so they're already minimal.)Both preserve prior malformed-row behavior:
DeleteKeyskips accounting/cleanup (as it did on aproto.Unmarshalerror — the metadata row is still deleted), and the listing loop treats the row as non-expired and includes the key.Test
storage/value_wire_test.gogains a differential test forvalueMessageExpiry(across shapes) and forunmarshalValueMessageSkippingData(asserts every field exceptDatamatches a full decode, andDatais dropped), plus a malformed-input case. Fullmake test-storagepasses.Provenance
Perfloop frontier cases
case_1mzwqcjjvr(DeleteKey) andcase_527g56fg8z(key listing), patternavoidable_copy, confirmed against source. Same family as #207.🤖 Generated with Claude Code