Skip to content

TreeDB/caching: reserve pointer batch index metadata - #3528

Open
snissn wants to merge 1 commit into
mainfrom
codex/3526-setwithrevision
Open

TreeDB/caching: reserve pointer batch index metadata#3528
snissn wants to merge 1 commit into
mainfrom
codex/3526-setwithrevision

Conversation

@snissn

@snissn snissn commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Classifies the Ironbird Batch.SetWithRevision allocation as required plain-Set caller-ownership copy plus pointer-batch metadata/slice growth, not duplicate stable-view copying.
  • Lazily reserves ptrValueIdxs from the existing batch int-slice pool when a batch first stages pointer-sized values, and returns that slice on Close.
  • Adds a focused BenchmarkBatchSetWithRevisionAllocationShape gate covering inline SetWithRevision, pointer SetWithRevision, and the existing stable-view no-copy path.

Evidence

Issue heap-profile peeks saved under /mnt/fast4tb/tmp/gomap-3526-setwithrevision-20260706T085722Z:

  • plain-send: Batch.SetWithRevision 1161.37MB flat / 1611.14MB cum of 111336.25MB total; child allocations are clonePtrValue 216.18MB, cloneKeyValue 208.34MB, cloneKey 25.25MB.
  • small-multisend: Batch.SetWithRevision 3249.35MB flat / 3774.08MB cum of 138570.57MB total; child allocations are clonePtrValue 495.11MB, cloneKeyValue 17.62MB, cloneKey 12.01MB.

Focused benchmark artifact root: /mnt/fast4tb/tmp/gomap-3526-setwithrevision-20260706T085722Z

benchstat bench_setwithrevision_count5.txt bench_setwithrevision_after_count5.txt:

  • SetWithRevision_pointer_64x32x2048: 2.349KiB/op -> 1.286KiB/op (-45.24%); 20 allocs/op -> 13 allocs/op (-35.00%); 8.200us/op -> 8.019us/op (-2.21%).
  • SetWithRevision_inline_64x32x96: allocation result statistically unchanged.
  • SetViewValidatedWithRevision_pointer_64x32x2048: 640 B/op and 1 alloc/op unchanged.

Focused alloc_space profile delta:

  • before: SetWithRevision 993.20kB flat / 1.87MB cum; line ptrValueIdxs = append(...) accounts for the flat allocation.
  • after: SetWithRevision 0 flat / 956.87kB cum; appendPtrValueIdx accounts for 4.50kB in the 1000x profile sample.

Tests

  • GOWORK=off TMPDIR=/mnt/fast4tb/tmp go test ./TreeDB/caching -run 'TestBatchCloseReleasesAuxiliaryIndexSlices|TestBatchAppendPtrValueIdxReservesEntryCapacity|TestBatchPtrValueArena'
  • GOWORK=off TMPDIR=/mnt/fast4tb/tmp go test ./TreeDB/caching
  • GOWORK=off TMPDIR=/mnt/fast4tb/tmp go test ./TreeDB/caching -run '^$' -bench 'BenchmarkBatchSetWithRevisionAllocationShape' -benchmem -count=5
  • GOWORK=off TMPDIR=/mnt/fast4tb/tmp go test ./TreeDB/caching -run '^$' -bench '^BenchmarkBatchSetWithRevisionAllocationShape/SetWithRevision_pointer_64x32x2048$' -benchmem -benchtime=1000x -count=1 -memprofile /mnt/fast4tb/tmp/gomap-3526-setwithrevision-20260706T085722Z/setwithrevision_pointer_after_mem.pprof -memprofilerate=1

No AI review requested. Not merged.

Fixes #3526

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@snissn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 14 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3126a7f8-b510-455c-a11f-4724437f390d

📥 Commits

Reviewing files that changed from the base of the PR and between 1893735 and a2292ba.

📒 Files selected for processing (3)
  • TreeDB/caching/batch_aux_pool_test.go
  • TreeDB/caching/batch_setwithrevision_bench_test.go
  • TreeDB/caching/db.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/3526-setwithrevision

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

TreeDB alloc loop: minimize Ironbird Batch.SetWithRevision allocations

1 participant