Skip to content

feat: add configurable SlateDB flush interval and group commit hook - #414

Open
alexskinner wants to merge 1 commit into
KipData:mainfrom
alexskinner:upstream/slatedb-durability-hook
Open

alexskinner wants to merge 1 commit into
KipData:mainfrom
alexskinner:upstream/slatedb-durability-hook

Conversation

@alexskinner

Copy link
Copy Markdown
Collaborator

Add open_with_settings and open_s3_with_settings so callers can pass SlateDB Settings such as flush_interval.

Also track the latest WriteHandle across storage clones via last_write, so concurrent committers can share one WAL flush instead of each waiting for durability independently.

Includes unit tests covering open_with_settings and shared flush waiting (last_write_awaits_the_latest_commit).

Add open_with_settings and open_s3_with_settings so callers can set SlateDB
Settings such as flush_interval. Track the latest WriteHandle across storage
clones via last_write, so concurrent committers can share one WAL flush
instead of each waiting for durability on their own.

Co-authored-by: Alex Skinner <alexskinner@users.noreply.github.com>
@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.08%. Comparing base (34a2123) to head (7f005e1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #414   +/-   ##
=======================================
  Coverage   93.08%   93.08%           
=======================================
  Files         282      282           
  Lines       39885    39885           
=======================================
  Hits        37125    37125           
  Misses       2760     2760           
Flag Coverage Δ
rust 93.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KKould

KKould commented Nov 27, 2026

Copy link
Copy Markdown
Member

I am particularly sensitive when it comes to the use of locks—which is likely why you won’t find any locks being used in KiteSQL. It seems this PR attempts to allow different operations to participate in the same group commit; however, wouldn't it be better to approach this optimization from the perspective of the Storage trait, rather than implementing it solely within SlateDB? Also, are you pursuing this optimization because SlateDB is currently facing performance issues? I’ve recently been working on a PR: slatedb/slatedb#2245 to optimize other parts of the system.

@KKould
KKould self-requested a review December 3, 2026 20:33
@alexskinner

Copy link
Copy Markdown
Collaborator Author

Thanks for the review, and sorry for the slow reply. I re-measured before answering, so this has numbers instead of opinions.

Is SlateDB having a performance problem? No, and #2245 (the read path) is not what I am hitting. The cost is durable commits: with await_durable(true) a commit returns once its WAL is flushed, which takes up to flush_interval (default 100 ms) plus one object store PUT. A caller that issues many small statements, each its own commit, from one connection pays one interval per statement. A workload of about 5,000 such statements took 289 s with the default 100 ms interval and 43 s with flush_interval = 5ms. Same workload, only that setting changed (local MinIO, one connection).

Micro-benchmark. SlateDbStorage on local MinIO, one small key per commit, 8 s per cell (a single run each), commits per second. await_durable(true) unless noted.

flush_interval commit pattern 1 writer 8 writers 32 writers
100 ms (default) no caller lock 10 80 320
100 ms caller lock held through the durability wait 10 11 14
100 ms lock released, wait on last_write() (this PR) 10 80 320
100 ms lock released, then Db::flush() 640 674 602
5 ms no caller lock 160 1297 5129
5 ms caller lock held through the durability wait 164 163 165
5 ms lock released, wait on last_write() (this PR) 159 1264 5199
5 ms lock released, then Db::flush() 690 608 711

What I take from it:

  1. The flush interval is the lever, and it needs no change in KiteSQL: SlateDbStorage::new(Arc<Db>) already accepts a Db built with any Settings. So open_with_settings / open_s3_with_settings are not needed.
  2. KiteSQL does not need group commit. With no caller-side lock, concurrent commits already share SlateDB's WAL flush (rows 1 and 5). It only matters when a caller serializes its commits and holds that lock across the durability wait (rows 2 and 6), which is the caller's choice, not something the storage should paper over.
  3. last_write() fixes that case, but through the shared Mutex you object to, and I agree it should not live in the storage. A caller can already release its lock and call Db::flush() with no KiteSQL change (rows 4 and 8). At a 5 ms interval it is slower than sharing a flush with 8 and 32 writers; at the default interval it is faster, and it is the best option for one writer. It needs no new API.

Proposal: drop open_with_settings, open_s3_with_settings and last_write() (and the Mutex) from this PR, so storage stays as it is. If you would like the single-writer case supported at the Storage trait level, the lock-free shape I would suggest is a StorageTransaction::commit_deferred(self) that returns a future for the durability wait, with a default implementation that commits and returns an already-ready future; SlateDB would return the commit's WriteHandle::await_durable. All state lives in the returned value, so there is no shared state and no lock. I will not open that unless you want it. If you do not, I will close this PR.

Caveat: a PUT on local MinIO takes about 1.4 ms (the p50 of the Db::flush() rows). Real S3 PUTs are slower, so the interval matters more there and the Db::flush() option gets relatively worse. I have not measured against S3.

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.

2 participants