Skip to content

perf: add concurrent keyspace mode (--concurrent flag) - #50

Merged
kacy merged 2 commits into
mainfrom
perf/concurrent-keyspace
Feb 7, 2026
Merged

perf: add concurrent keyspace mode (--concurrent flag)#50
kacy merged 2 commits into
mainfrom
perf/concurrent-keyspace

Conversation

@kacy

@kacy kacy commented Feb 7, 2026

Copy link
Copy Markdown
Owner

summary

adds an experimental --concurrent flag that uses DashMap for lock-free concurrent access, bypassing the sharded channel architecture for GET/SET commands.

benchmark results

IMPORTANT: previous benchmarks used single-threaded redis-benchmark, which bottlenecked the client. With --threads 8, the true scaling behavior is revealed:

mode SET (ops/sec) GET (ops/sec)
sharded (tokio channels) 881k 994k
concurrent (DashMap) 1,795k 2,653k
redis 1,018k 1,205k

concurrent mode is:

  • 2x faster than sharded mode
  • 1.76x faster than Redis for SET
  • 2.2x faster than Redis for GET

tested on GCP c2-standard-8 (8 vCPU Intel Xeon @ 3.10GHz)

what's new

  • ConcurrentKeyspace: DashMap-backed keyspace with lock-free access
  • --concurrent flag: enables the new mode
  • supports GET, SET, DEL, EXISTS, EXPIRE, TTL, PING, ECHO, DBSIZE, FLUSHDB
  • unsupported commands return an error (lists, hashes, sorted sets, etc.)

root cause analysis

the sharded architecture has significant channel overhead:

connection handler → mpsc send → shard task → oneshot reply → connection handler

every request crosses thread boundaries twice. with DashMap, connection handlers access the keyspace directly without any channel coordination.

design considerations

this is a tradeoff:

  • pros: eliminates channel overhead, 2x+ better throughput
  • cons: loses strict per-shard isolation, no persistence support yet

the concurrent mode is marked experimental. full feature parity with the sharded mode would require more work (lists, hashes, sorted sets, persistence).

what was tested

  • all 223 core tests pass
  • multi-threaded benchmarks show 2x improvement over sharded mode
  • beats Redis by 1.76-2.2x on GET/SET

adds an experimental mode that uses DashMap for lock-free concurrent
access, bypassing the sharded channel architecture for GET/SET commands.

benchmark results on 8-core VM:
- SET: +13% throughput (1,010k → 1,142k ops/sec)
- GET: +11% throughput (1,115k → 1,241k ops/sec)

the improvement comes from eliminating the per-request channel overhead
(mpsc send + oneshot reply) that exists in the sharded architecture.

new files:
- concurrent.rs: DashMap-backed ConcurrentKeyspace
- concurrent_handler.rs: connection handler for concurrent mode

usage: ember-server --concurrent
@kacy
kacy merged commit 03a563f into main Feb 7, 2026
@kacy
kacy deleted the perf/concurrent-keyspace branch February 7, 2026 20:04
kacy added a commit that referenced this pull request Feb 11, 2026
* perf: add concurrent keyspace mode (--concurrent flag)

adds an experimental mode that uses DashMap for lock-free concurrent
access, bypassing the sharded channel architecture for GET/SET commands.

benchmark results on 8-core VM:
- SET: +13% throughput (1,010k → 1,142k ops/sec)
- GET: +11% throughput (1,115k → 1,241k ops/sec)

the improvement comes from eliminating the per-request channel overhead
(mpsc send + oneshot reply) that exists in the sharded architecture.

new files:
- concurrent.rs: DashMap-backed ConcurrentKeyspace
- concurrent_handler.rs: connection handler for concurrent mode

usage: ember-server --concurrent

* chore: fmt and clippy fixes
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