Skip to content

perf(storage): skip inline payload decoding in cleaner scans - #238

Merged
ovaistariq merged 2 commits into
mainfrom
perfloop-pr-open-1pay7nk3xj
Aug 22, 2026
Merged

ovaistariq merged 2 commits into
mainfrom
perfloop-pr-open-1pay7nk3xj

Conversation

@perfloop

@perfloop perfloop Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

The change

Cleaner reconciliation now reads value_length from the ValueMessage wire data, and TTL cleanup reads expiry first. Inline payloads and control messages are no longer reconstructed for ordinary non-expiring rows.

The scanner validates the complete record, including path UTF-8 and duplicate scalar fields. Expired rows still decode their control fields because file and segment reclamation needs them.

Testing

  • make test-storage-wire
  • make test-storage-reconcile

Workload: uncapped hourly cleanup-loop reconciliation with the default 64 MiB compaction threshold, 24 inline 64 KiB and 8 segment-converted 64 KiB+1 values

Metric Before After Change
B/op 3186729 28945 99.1% lower
allocs/op 912 783 14.1% lower

Workload: capped LRU-backfill cleanup-loop reconciliation with 32 inline 64 KiB values

Metric Before After Change
B/op 4239035 34853 99.2% lower
allocs/op 1624 1491 8.2% lower
Checks: 2 passed.

Generated by Perfloop. Measurements and checks.


Note

Medium Risk
Touches cleaner TTL and metadata-scan validation, which drive size accounting and eviction. Behavior is intended to match full protobuf decode, but a wire-parser mismatch could skip or delete the wrong rows.

Overview
TTL cleanup no longer fully unmarshals every metadata row. It reads expiry off the wire and only reconstructs control fields (still skipping inline Data) for expired keys that need file/segment reclaim.

Wire extractors now reject invalid protobuf field numbers and non-UTF-8 path strings, matching proto.Unmarshal, so malformed rows stay skipped for size accounting and deleted on TTL scan.

Adds a scheduled cleanupLoop reconciliation benchmark/test (capped LRU backfill and uncapped hourly recalc) plus Makefile targets build-storage-bench, test-storage-wire, and test-storage-reconcile. lastSizeRecalc and onTickComplete exist so tests can drive a single tick without changing cleaner work.

Reviewed by Cursor Bugbot for commit e54cd8f. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown

Greptile Summary

Cleaner scans now extract expiry and value length directly from protobuf wire data, avoiding reconstruction and copying of inline payloads while retaining full-record validation.

  • Updates TTL cleanup to decode control fields only for expired rows.
  • Adds wire-format validation and parity tests for malformed data, duplicate scalar fields, and UTF-8 paths.
  • Adds scheduled reconciliation benchmarks and focused Makefile test targets.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code failure identified.

The wire-level scanners preserve protobuf scalar and validation semantics on reachable cleaner paths, while expired rows still decode the control metadata needed for size accounting and backing-storage reclamation.

Important Files Changed

Filename Overview
storage/cleaner.go Replaces full protobuf decoding in ordinary TTL and reconciliation scans with validated wire-field extraction while preserving expired-row accounting and reclamation.
storage/value_wire.go Adds complete wire traversal, path UTF-8 validation, and lightweight expiry/value-length extraction without materializing inline data.
storage/value_wire_test.go Expands extractor parity and malformed-wire coverage, including duplicate fields, invalid field numbers, invalid UTF-8, and skipped payloads.
storage/cleaner_reconciliation_bench_test.go Adds timer-driven reconciliation tests and benchmarks for capped, uncapped, inline, and segment-converted fixtures.
Makefile Adds focused storage test targets and a benchmark-binary build target with the repository’s CGO configuration.

Reviews (1): Last reviewed commit: "perf(storage): skip inline payload decod..." | Re-trigger Greptile

@ovaistariq
ovaistariq merged commit f6647b6 into main Aug 22, 2026
12 of 13 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-1pay7nk3xj branch August 22, 2026 20:21
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.12.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.

4 participants