Skip to content

kv: add --shim unix, rudb behind a socket for the PostgreSQL comparison - #273

Merged
tamnd merged 1 commit into
mainfrom
kv-shim
Oct 6, 2026
Merged

tamnd merged 1 commit into
mainfrom
kv-shim

Conversation

@tamnd

@tamnd tamnd commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Part of tamnd/rudb#1388 (W5).

rudb runs in the driver's process, and PostgreSQL runs behind a Unix socket. So a comparison between them measures the socket as much as the engine. The OLTP Looking Glass measurement (CIDR 2025) puts about 70% of a point transaction's cycles in that kind of communication.

This adds --shim unix, the shim of engine-v4 section 13.8 and the YCSB spec's section 4.10:

  • Each session gets a socketpair and a thread on the other end, and that thread owns the engine's session. The client writes a length-prefixed request (the operation, the statement index and its parameters) and blocks on the read. The thread runs the request and writes back the whole result: the row count, then each value, length-prefixed.
  • That is one round trip through the kernel per statement and one thread per connection, the same shape as PostgreSQL's backend per connection. BEGIN, COMMIT, ROLLBACK, prepare and explain go over the socket too, so the engine's own session overrides still apply.
  • It works for rudb and null. The null run gives the shim's own cost.
  • Every header line now has boundary=in_process, unix_socket (PostgreSQL) or unix_shim, for both the YCSB and TPC-C modes.

On a loaded server2, null with 4 clients doing reads went from about 0.27 µs to about 2.9 µs per operation behind the shim. That gap is the round trip itself.

Tests: a unit test runs the same statements on a null session directly and through the shim and compares the values. A second test checks that a frame larger than the socket buffer arrives whole, and that one cut short is an error. Argument parsing tests cover --shim. cargo test and cargo clippy --all-targets -D warnings pass on server2, and a --mode tpcc --backend null --shim unix run completes end to end.

Each session gets a socketpair and a thread that owns the engine's session, so every statement pays one round trip through the kernel, the shape of PostgreSQL's backend per connection. The header gains boundary=in_process|unix_socket|unix_shim so every number says which it is.
@tamnd
tamnd merged commit adcb147 into main Oct 6, 2026
@tamnd
tamnd deleted the kv-shim branch October 6, 2026 12:02
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