Skip to content

Add WithSyncInterval option for delayed BBolt disk flushes - #4

Draft
reinkrul wants to merge 1 commit into
mainfrom
delayed-flush
Draft

Add WithSyncInterval option for delayed BBolt disk flushes#4
reinkrul wants to merge 1 commit into
mainfrom
delayed-flush

Conversation

@reinkrul

@reinkrul reinkrul commented Jun 10, 2022

Copy link
Copy Markdown
Member

Summary

  • Adds WithSyncInterval(interval) option: instead of fsyncing after every transaction commit, a background goroutine batches pending writes and flushes at most once per interval
  • Close() always flushes any dirty writes before shutting down, so no data is silently lost on clean shutdown
  • WithNoSync() behaviour is unchanged (backwards compatible)
  • Config.SyncInterval and Config.DelayedSync() helper added for backend implementors

Test plan

  • TestBBolt_SyncInterval/data_is_flushed_on_close_when_dirty — writes survive a clean close
  • TestBBolt_SyncInterval/data_is_flushed_periodically — background goroutine fires within interval
  • BenchmarkBBolt_Flush — compare throughput of per-commit sync vs. interval sync
  • All existing tests pass (go test ./...)

🤖 Generated with Claude Code

@reinkrul
reinkrul requested a review from woutslakhorst June 10, 2022 06:55
…terval

Instead of syncing after every transaction commit, the store batches pending
writes and flushes them at most once per interval via a background goroutine.
Close() always flushes any remaining dirty writes before shutting down.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@reinkrul reinkrul changed the title Allow BBolt to flush to disk at set interval instead of on every TX commit Add WithSyncInterval option for delayed BBolt disk flushes Apr 10, 2026
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.

1 participant