Skip to content

caching: adaptive append-only lease reset capacity hint#831

Open
snissn wants to merge 6 commits intopr/vlog-mmap-expvar-telemetryfrom
pr/append-only-retention-entry-hint
Open

caching: adaptive append-only lease reset capacity hint#831
snissn wants to merge 6 commits intopr/vlog-mmap-expvar-telemetryfrom
pr/append-only-retention-entry-hint

Conversation

@snissn
Copy link
Copy Markdown
Owner

@snissn snissn commented Mar 15, 2026

Summary

  • add a bounded/decayed appendOnlyEntryHint from observed append-only mutable sizes at shard rotation
  • apply the hint only to append-only lease/recycle hard resets (ResetWithCapacityHard) so retained memtables do not keep oversized entry slices after spikes
  • keep active mutable creation sizing unchanged (avoids the regrowth churn regression)
  • export hint telemetry in stats:
    • treedb.cache.append_only.entry_hint_entries
    • treedb.cache.append_only.entry_hint_capacity_bytes
    • process mirrors
  • add focused tests in TreeDB/caching/append_only_hint_test.go

Validation

  • go test ./TreeDB/caching -count=1
  • go test ./TreeDB/internal/memtable -count=1
  • go test ./TreeDB/db -run TestDoesNotExist -count=1
  • go vet ./TreeDB/caching

Unified Bench (serial, same args)

Candidate profile dir: /home/mikers/tmp/perf-append-hint-v2-1773568813
Baseline profile dir: /home/mikers/tmp/perf-append-hint-base-1773568648

Throughput deltas (TreeDB):

  • sequential_write: +12.59%
  • random_write: -4.58%
  • dataset_write_random: -4.64%
  • batch_write: +5.05%
  • batch_write_steady: +1.95%
  • random_read: -0.40%

Alloc-space deltas (TreeDB):

  • sequential_write total: 199.24MB -> 138.21MB (-30.63%)
  • random_write total: 30,410.35kB -> 24,557.59kB (-19.25%)
  • batch_write_steady total: 155.64MB -> 141.77MB (-8.91%)

Celestia runs (this branch)

fast:

  • /home/mikers/.celestia-app-mainnet-treedb-20260315000234
    • duration_seconds=303
    • max_rss_kb=11869152
    • end_app_bytes=4745471322
  • /home/mikers/.celestia-app-mainnet-treedb-20260315001415
    • duration_seconds=293
    • max_rss_kb=10193048
    • end_app_bytes=4813039808

wal_on_fast:

  • /home/mikers/.celestia-app-mainnet-treedb-20260315000807
    • duration_seconds=336
    • max_rss_kb=10134740
    • end_app_bytes=4686263016
  • /home/mikers/.celestia-app-mainnet-treedb-20260315001936
    • duration_seconds=349
    • max_rss_kb=11439180
    • end_app_bytes=4876966298

Notes:

Copilot AI review requested due to automatic review settings March 15, 2026 10:26
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 adds an adaptive sizing hint for append-only memtable hard resets (lease recycle/trim) based on recently observed mutable sizes at shard rotation, aiming to avoid retaining oversized entry slices after workload spikes while keeping active mutable sizing unchanged.

Changes:

  • Track a bounded/decayed appendOnlyEntryHint from observed append-only mutable entry counts during shard rotation.
  • Apply the hint only when calling ResetWithCapacityHard for append-only memtables during recycle/lease trimming.
  • Export the hint in DB.Stats() and add focused unit tests for decay/clamping and overflow behavior.

Reviewed changes

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

File Description
TreeDB/caching/db.go Adds adaptive append-only entry hint tracking, applies it to append-only hard resets, and exports hint telemetry via Stats().
TreeDB/caching/append_only_hint_test.go Adds tests covering hint decay/clamping and overflow-safe capacity computation.

💡 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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e861bf791

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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 introduces an adaptive, bounded “append-only entry hint” in caching.DB to better size append-only memtable hard resets (lease/pool recycle paths) based on recently observed mutable shard sizes, reducing post-spike retained entry-slice over-allocation while keeping active mutable sizing unchanged.

Changes:

  • Track a decayed/clamped appendOnlyEntryHint (observed at mutable shard rotation) and use it to compute an effective capacity for append-only ResetWithCapacityHard paths.
  • Export the hint as stats under both treedb.cache.append_only.* and treedb.process.append_only.*.
  • Add focused unit tests covering decay/clamping and overflow safety.

Reviewed changes

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

File Description
TreeDB/caching/db.go Adds append-only hint tracking, applies hinted capacity to append-only hard resets, and exports hint telemetry in Stats().
TreeDB/caching/append_only_hint_test.go Adds tests for hint decay/clamping behavior and overflow-safe capacity derivation.

💡 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.

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

Adds an adaptive (bounded + decayed) append-only entry slice sizing hint derived from observed append-only mutable sizes at shard rotation, and applies it only when hard-resetting/recycling append-only memtables to avoid retaining oversized entry slices after spikes.

Changes:

  • Track an appendOnlyEntryHint on DB, updated on append-only shard rotation using a grow/decay filter.
  • Apply the hint when calling ResetWithCapacityHard for append-only memtables during recycle/lease trimming.
  • Export hint telemetry via cache/process stats and add focused tests for decay/clamping and overflow safety.

Reviewed changes

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

File Description
TreeDB/caching/db.go Implements the adaptive hint, applies it to append-only hard resets, and exports stats telemetry.
TreeDB/caching/append_only_hint_test.go Adds tests validating hint decay/clamping behavior and overflow-safe capacity conversion.

💡 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.

Copilot AI review requested due to automatic review settings March 18, 2026 20:33
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 introduces an adaptive, bounded, and decaying appendOnlyEntryHint in the caching DB to better size recycled/leased append-only memtables after transient spikes, aiming to reduce retained entry-slice memory while avoiding churn in active mutable sizing.

Changes:

  • Track an adaptive appendOnlyEntryHint based on observed append-only mutable entry counts at shard rotation.
  • Apply the hint when performing append-only lease/recycle hard resets (ResetWithCapacityHard) to cap retained capacity after spikes.
  • Export hint telemetry via new treedb.cache.* and treedb.process.* stats keys, and add focused unit tests for the hint logic.

Reviewed changes

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

File Description
TreeDB/caching/db.go Adds adaptive hint tracking, applies it to append-only hard-reset capacity during recycling/lease trimming, and exports new stats.
TreeDB/caching/append_only_hint_test.go Adds unit tests validating hint decay behavior and overflow-safe capacity conversion.

💡 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.

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