Skip to content

perf(storage): retain decoded inline values - #244

Merged
ovaistariq merged 4 commits into
mainfrom
perfloop-pr-open-y5xpg2ck2q
Aug 28, 2026
Merged

ovaistariq merged 4 commits into
mainfrom
perfloop-pr-open-y5xpg2ck2q

Conversation

@perfloop

@perfloop perfloop Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

The change

ListKeyValuesWithPagination now retains the protobuf decoder's owned Data for capped INLINE values instead of allocating and copying it a second time. The decoder still separates the data from the RocksDB iterator, which is closed after decoding. The existing size cap and SEGMENT/RAW_FILE branches are unchanged.

The service benchmark covers 4 KiB and 64 KiB inline values at page sizes of 1, 100, and 1,000.

Testing:

  • make lint
  • make license-check
  • make test-server TEST=TestCacheService_ListWithValuesRetainsInlineData
  • make test-storage TEST=TestListKeyValuesWithPagination_OmitsOversizeValues

Workload: ListWithValues INLINE 4 KiB page of 1

Metric Before After Change
B/op 8960 4864 45.7% lower

Workload: ListWithValues INLINE 4 KiB page of 100

Metric Before After Change
B/op 879784 470178 46.6% lower

Workload: ListWithValues INLINE 4 KiB page of 1,000

Metric Before After Change
B/op 8755286 4659241 46.8% lower

Workload: ListWithValues INLINE 64 KiB page of 1

Metric Before After Change
B/op 131842 66305 49.7% lower

Workload: ListWithValues INLINE 64 KiB page of 100

Metric Before After Change
B/op 13167872 6614218 49.8% lower

Workload: ListWithValues INLINE 64 KiB page of 1,000

Metric Before After Change
B/op 131635753 66099483 49.8% lower
Checks: 4 passed.

Generated by Perfloop. Measurements and checks.


Note

Medium Risk
Changes memory ownership on a hot list path; mitigated by a regression test that closes storage before asserting value bytes, but incorrect assumptions about protobuf decode lifetimes could cause subtle corruption.

Overview
List-with-values for inline objects no longer allocates and copies payload bytes after proto.Unmarshal; it reuses the decoder-owned Data slice instead, cutting roughly half the bytes allocated per ListWithValues call in the reported benchmarks. Oversize omission, segment, and raw-file read paths are unchanged.

Adds BenchmarkCacheServiceListWithValues (4 KiB / 64 KiB × page sizes 1, 100, 1000) plus TestCacheService_ListWithValuesRetainsInlineData, which closes storage after the list returns to prove returned inline bytes are not tied to RocksDB iterator memory. The Makefile gains build-bench-cache-service-list-with-values for precompiled Perfloop runs.

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

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown

Greptile Summary

The PR removes a redundant copy when returning decoded INLINE values from paginated storage listings while preserving ownership beyond the RocksDB iterator lifetime.

  • Adds service benchmarks for 4 KiB and 64 KiB inline values across page sizes of 1, 100, and 1,000.
  • Adds a lifecycle test that validates returned values after storage closes.
  • Adds a Makefile target for compiling the ListWithValues benchmark binary.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, build, or benchmark issues identified.

The decoded inline bytes have independent ownership, are not reused or mutated in the response path, and the added benchmark cases remain within the list limits.

Important Files Changed

Filename Overview
storage/storage.go Reuses the protobuf decoder-owned INLINE byte slice instead of making a redundant second copy; ownership remains independent of iterator memory.
server/service/list_with_values_benchmark_test.go Adds representative allocation benchmarks and verifies inline response data remains valid after storage shutdown.
Makefile Adds a benchmark compilation target consistent with existing service benchmark targets.

Reviews (1): Last reviewed commit: "test: guard list fixture cleanup" | Re-trigger Greptile

@ovaistariq
ovaistariq merged commit 29482a9 into main Aug 28, 2026
13 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-y5xpg2ck2q branch August 28, 2026 21:18
@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.

3 participants