Skip to content

Conversation

@wolf31o2
Copy link
Member

@wolf31o2 wolf31o2 commented Dec 28, 2025


Summary by cubic

Add a configurable Badger value threshold to control when values stay in LSM vs the value log, defaulting to 1MB. Also increases the default memtable size to 128MB for better write buffering.

  • New Features
    • New value-threshold option (default 1MB); exposed via plugin CLI and wired to Badger.
    • Added WithValueThreshold option for programmatic config.
    • Increased DefaultMemTableSize to 128MB.

Written for commit b02bf2f. Summary will update automatically on new commits.

Summary by CodeRabbit

  • New Features
    • Added a configurable value-threshold for the database storage backend to control where values are stored (default: 1 MB).
    • Increased the default memory table size from 64 MB to 128 MB to improve storage performance.

✏️ Tip: You can customize this high-level summary in your review settings.

@wolf31o2 wolf31o2 requested a review from a team as a code owner December 28, 2025 18:13
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

Adds configurable value-threshold support to the Badger blob store plugin. Introduces a valueThreshold int64 field on BlobStoreBadger initialized from exported DefaultValueThreshold (1MB), exposes a WithValueThreshold(threshold int64) option function and a value-threshold command-line flag with bounds checking, and wires the threshold into Badger options for both in-memory and on-disk initialization paths. Also increases DefaultMemTableSize from 64MB to 128MB.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically describes the main change: adding a configurable value threshold feature to the Badger plugin for the database component.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/badger-value-threshold

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a55051b and b02bf2f.

📒 Files selected for processing (3)
  • database/plugin/blob/badger/database.go
  • database/plugin/blob/badger/options.go
  • database/plugin/blob/badger/plugin.go
🧰 Additional context used
🧬 Code graph analysis (3)
database/plugin/blob/badger/options.go (1)
database/plugin/blob/badger/database.go (1)
  • BlobStoreBadger (147-161)
database/plugin/blob/badger/plugin.go (2)
database/plugin/option.go (1)
  • PluginOptionTypeUint (32-32)
database/plugin/blob/badger/options.go (1)
  • WithValueThreshold (84-88)
database/plugin/blob/badger/database.go (2)
database/plugin/blob/badger/plugin.go (1)
  • DefaultValueThreshold (29-29)
database/plugin/blob/badger/options.go (1)
  • WithValueThreshold (84-88)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: go-test (1.24.x, macos-latest)
  • GitHub Check: go-test (1.24.x, windows-latest)
  • GitHub Check: go-test (1.25.x, windows-latest)
  • GitHub Check: nilaway
  • GitHub Check: Analyze (go)
🔇 Additional comments (10)
database/plugin/blob/badger/options.go (1)

82-88: LGTM!

The WithValueThreshold option function follows the established pattern of other option functions in this file. The int64 parameter type correctly matches the valueThreshold field type in BlobStoreBadger and aligns with Badger's WithValueThreshold API.

database/plugin/blob/badger/database.go (4)

159-159: LGTM!

The new valueThreshold field is correctly typed as int64 to match Badger's API.


172-172: LGTM!

Default initialization is consistent with other size parameters in the struct.


187-188: LGTM!

Applying WithValueThreshold to the in-memory path ensures consistent behavior regardless of storage mode.


215-215: LGTM!

The value threshold is correctly wired into the on-disk Badger options chain.

database/plugin/blob/badger/plugin.go (5)

39-39: LGTM!

The uint64 type is consistent with other size-related CLI options in the struct.


53-53: LGTM!

Default initialization follows the established pattern.


110-116: LGTM!

The CLI option registration follows the established pattern and is consistent with other size-based options like memtable-size and value-log-file-size.


133-150: LGTM!

The bounds checking correctly caps at max int64 before conversion, following the same pattern used for valueLogFileSize and memTableSize. The option is properly wired into the options slice.


28-29: LGTM!

The DefaultMemTableSize increase to 128MB provides better write buffering, and the new DefaultValueThreshold of 1MB matches Badger v4's default for keeping smaller values inline in the LSM tree while directing larger blobs to the value log.


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 and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@wolf31o2 wolf31o2 force-pushed the feat/badger-value-threshold branch from a55051b to 7b99788 Compare December 28, 2025 18:16
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
database/plugin/blob/badger/database.go (1)

181-191: Apply WithValueThreshold(db.valueThreshold) to the in-memory Badger configuration.

The valueThreshold is applied to the on-disk configuration (line 214) but missing from the in-memory configuration (lines 181-191). According to Badger documentation, WithValueThreshold should be applied to both configurations as it controls value-log placement in the LSM tree organization, even for in-memory mode. The value threshold has already been initialized at line 172, so it should be consistently applied to both paths:

badgerOpts := badger.DefaultOptions("").
    WithLogger(NewBadgerLogger(db.logger)).
    WithLoggingLevel(badger.WARNING).
    WithInMemory(true).
    WithValueThreshold(db.valueThreshold)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b96a0f and a55051b.

📒 Files selected for processing (3)
  • database/plugin/blob/badger/database.go
  • database/plugin/blob/badger/options.go
  • database/plugin/blob/badger/plugin.go
🧰 Additional context used
🧬 Code graph analysis (3)
database/plugin/blob/badger/database.go (2)
database/plugin/blob/badger/plugin.go (1)
  • DefaultValueThreshold (29-29)
database/plugin/blob/badger/options.go (1)
  • WithValueThreshold (84-88)
database/plugin/blob/badger/plugin.go (2)
database/plugin/option.go (1)
  • PluginOptionTypeUint (32-32)
database/plugin/blob/badger/options.go (1)
  • WithValueThreshold (84-88)
database/plugin/blob/badger/options.go (1)
database/plugin/blob/badger/database.go (1)
  • BlobStoreBadger (147-161)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: nilaway
  • GitHub Check: go-test (1.24.x, macos-latest)
  • GitHub Check: go-test (1.24.x, windows-latest)
  • GitHub Check: go-test (1.25.x, ubuntu-latest)
  • GitHub Check: go-test (1.25.x, windows-latest)
  • GitHub Check: go-test (1.25.x, macos-latest)
  • GitHub Check: Analyze (go)
🔇 Additional comments (9)
database/plugin/blob/badger/options.go (1)

82-88: LGTM!

The WithValueThreshold option function follows the established pattern used by other option functions in this file (WithMemTableSize, WithValueLogFileSize, etc.).

database/plugin/blob/badger/database.go (3)

159-159: LGTM!

The valueThreshold field is correctly added to the struct, consistent with the other size-related fields.


172-172: LGTM!

Good initialization with DefaultValueThreshold and helpful inline comment explaining the purpose.


207-215: LGTM!

The WithValueThreshold is correctly integrated into the Badger options chain for on-disk storage.

database/plugin/blob/badger/plugin.go (5)

28-29: Note: DefaultMemTableSize doubled from 64MB to 128MB.

This is a behavioral change that will increase memory usage for existing deployments. The new DefaultValueThreshold of 1MB is a reasonable default for Badger's value log separation policy.

Consider documenting this default change in release notes, as it affects memory consumption for existing users upgrading to this version.


39-39: LGTM!

The valueThreshold field is correctly added to the command-line options structure with uint64 type, matching other size-related options.


53-53: LGTM!

Correct initialization of valueThreshold with the default constant.


110-116: LGTM!

The value-threshold command-line option is correctly registered following the established pattern for other size-related options.


133-150: LGTM!

The bounds checking for valueThreshold follows the established pattern used for valueLogFileSize and memTableSize. The conversion to int64 is safe after the bounds check.

@wolf31o2 wolf31o2 force-pushed the feat/badger-value-threshold branch from 7b99788 to b02bf2f Compare December 28, 2025 18:17
@wolf31o2 wolf31o2 merged commit 7c679b9 into main Dec 28, 2025
13 of 15 checks passed
@wolf31o2 wolf31o2 deleted the feat/badger-value-threshold branch December 28, 2025 18:39
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