Skip to content

caching: pool trimmed append-only mem leases#835

Open
snissn wants to merge 5 commits intopr/get-cap-trim-retentionfrom
pr/append-only-lease-trim-pool-reuse
Open

caching: pool trimmed append-only mem leases#835
snissn wants to merge 5 commits intopr/get-cap-trim-retentionfrom
pr/append-only-lease-trim-pool-reuse

Conversation

@snissn
Copy link
Copy Markdown
Owner

@snissn snissn commented Mar 15, 2026

Summary

  • when trimAppendOnlyMemLeases drops strong lease references, return the reset memtables to appendOnlyMemPool instead of discarding them
  • release any stale direct-arena lease association before pooling
  • add TestTrimAppendOnlyMemLeases_DroppedLeasesReturnToPool

Why

Previously, trim dropped append-only memtables on the floor after hard reset. That loses reusable entry-slice backing arrays and increases reallocation pressure on subsequent rotate cycles.

Validation

  • go test ./TreeDB/caching -run TestTrimAppendOnlyMemLeases_DroppedLeasesReturnToPool -count=50
  • go test ./TreeDB/caching ./TreeDB/internal/memtable -count=1
  • go vet ./TreeDB/caching ./TreeDB/internal/memtable
  • unified bench:
    • /home/mikers/tmp/perf-cap-trim-1773579157
    • /home/mikers/tmp/perf-lease-trim-pool-1773579424

Copilot AI review requested due to automatic review settings March 15, 2026 13:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves TreeDB caching’s post-flush/checkpoint trimming so that append-only memtables dropped from the strong “lease” set are reset and returned to the appendOnlyMemPool (and any stale direct-arena lease association is released) to reduce reallocation pressure on subsequent rotations.

Changes:

  • Pool dropped append-only memtables during trimAppendOnlyMemLeases instead of discarding them.
  • Release any associated append-only direct arena lease before pooling the memtable.
  • Add a unit test asserting trimmed leases are returned to the memtable pool.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
TreeDB/caching/db.go Returns dropped append-only memtables to appendOnlyMemPool after hard reset and direct-arena lease release.
TreeDB/caching/retained_arena_trim_test.go Adds a test intended to validate that trimmed append-only leases are pooled for reuse.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread TreeDB/caching/retained_arena_trim_test.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves memory reuse in the caching layer by ensuring append-only memtables dropped during lease trimming are returned to the per-DB appendOnlyMemPool, and by releasing any associated direct-arena leases before pooling.

Changes:

  • Return dropped append-only memtable leases to db.appendOnlyMemPool instead of discarding them.
  • Release any append-only direct-arena lease association before pooling dropped memtables.
  • Add a unit test intended to validate that trimmed leases are returned to the pool.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
TreeDB/caching/db.go Pools trimmed append-only memtables and releases direct-arena lease associations before pooling.
TreeDB/caching/retained_arena_trim_test.go Adds a test for verifying trimmed append-only leases are returned to the pool.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread TreeDB/caching/retained_arena_trim_test.go
Comment thread TreeDB/caching/db.go
Copilot AI review requested due to automatic review settings March 18, 2026 00:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improve append-only memtable lease trimming by pooling reset memtables (instead of discarding) and adding a regression test to ensure dropped leases are reusable, reducing allocation pressure during rotate cycles.

Changes:

  • Return dropped append-only memtables to appendOnlyMemPool after a hard reset.
  • Release stale direct-arena lease association before pooling.
  • Add a unit test covering the “dropped leases returned to pool” behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
TreeDB/caching/db.go Pools dropped append-only memtables during trimming and releases direct-arena lease associations.
TreeDB/caching/retained_arena_trim_test.go Adds a regression test asserting trimmed leases become available for reuse via the mem pool.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread TreeDB/caching/db.go
Comment thread TreeDB/caching/retained_arena_trim_test.go
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.

3 participants