Skip to content

perf: skip inline payload decode in DeleteKey and key listing - #208

Merged
ovaistariq merged 1 commit into
mainfrom
fix/delete-list-skip-payload-decode
Aug 14, 2026
Merged

ovaistariq merged 1 commit into
mainfrom
fix/delete-list-skip-payload-decode

Conversation

@ovaistariq

@ovaistariq ovaistariq commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #207 (now merged); rebased onto main. Reuses the value_wire.go wire-extractor helpers #207 introduced.

Problem

Two more read paths fully proto.Unmarshal each metadata row but never read ValueMessage.Data:

  • DeleteKey (storage/storage.go) — uses only the control fields (ValueType, ValueLength, RawFilePath, SegmentPath) for size accounting and file reclamation via stageFileDeletion.
  • ListKeysWithPagination — reads only Expiry to skip expired rows; it returns keys only.

Each copies the inline Data payload (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.go extractors from #207 (varint core factored out):

  • valueMessageExpiry reads expiry (field 3) off the wire → the listing loop no longer allocates a ValueMessage per scanned row at all.
  • unmarshalValueMessageSkippingData rebuilds the message wire without field 2 (Data) and defers to the generated decoder for the remaining small fields. This keeps exact proto semantics and stageFileDeletion's *pb.ValueMessage signature, while dropping the payload copy. (Raw-file/segment rows carry no Data, so they're already minimal.)

Both preserve prior malformed-row behavior: DeleteKey skips accounting/cleanup (as it did on a proto.Unmarshal error — 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.go gains a differential test for valueMessageExpiry (across shapes) and for unmarshalValueMessageSkippingData (asserts every field except Data matches a full decode, and Data is dropped), plus a malformed-input case. Full make test-storage passes.

Provenance

Perfloop frontier cases case_1mzwqcjjvr (DeleteKey) and case_527g56fg8z (key listing), pattern avoidable_copy, confirmed against source. Same family as #207.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR avoids copying inline payload data when deleting keys or listing key names.

  • Adds reusable wire-level extraction for scalar ValueMessage fields.
  • Reads expiry directly from encoded metadata during paginated key listing.
  • Strips inline data before decoding deletion control fields.
  • Adds differential tests covering normal message shapes and malformed input.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
storage/storage.go Routes key listing and deletion through payload-skipping metadata decoders while preserving their documented fallback behavior for ordinary malformed rows.
storage/value_wire.go Introduces wire-level expiry extraction and a decoder that removes inline data before unmarshalling the remaining control fields.
storage/value_wire_test.go Adds differential coverage for expiry extraction, payload omission, control-field preservation, and truncated malformed input.

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
ovaistariq force-pushed the fix/delete-list-skip-payload-decode branch from 1c8bd05 to 01b18a0 Compare August 14, 2026 18:00
@ovaistariq

Copy link
Copy Markdown
Contributor Author

@greptile

@ovaistariq
ovaistariq merged commit d919949 into main Aug 14, 2026
13 checks passed
@ovaistariq
ovaistariq deleted the fix/delete-list-skip-payload-decode branch August 14, 2026 18:35
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.10.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants