Skip to content

feat: criterion micro-benchmarks for hot path - #42

Merged
kacy merged 1 commit into
mainfrom
feat/criterion-benchmarks
Feb 7, 2026
Merged

feat: criterion micro-benchmarks for hot path#42
kacy merged 1 commit into
mainfrom
feat/criterion-benchmarks

Conversation

@kacy

@kacy kacy commented Feb 7, 2026

Copy link
Copy Markdown
Owner

summary

  • adds criterion benchmark suites for the two performance-critical crates on the hot path
  • benchmarks keyspace get/set at multiple value sizes (64B, 256B, 1KB, 16KB) to measure raw data structure performance
  • benchmarks engine routing (mpsc + oneshot channel round-trip) to measure async overhead
  • benchmarks RESP3 parsing, serialization, and command dispatch to measure protocol layer cost
  • adds bench, bench-core, bench-protocol Makefile targets

tested

  • cargo bench -p emberkv-core -- --test — all 14 benchmark cases compile and pass
  • cargo bench -p ember-protocol -- --test — all 9 benchmark cases compile and pass
  • cargo clippy --workspace -- -D warnings — clean
  • ran cargo bench -p emberkv-core -- keyspace_get/64B to verify real output (~45ns per GET on 64B value)

design considerations

  • keyspace benchmarks operate directly on Keyspace::new() without async or channels, isolating raw data structure performance from routing overhead
  • engine benchmarks use b.to_async(&rt) with a multi-thread tokio runtime to measure the real mpsc/oneshot channel cost
  • protocol benchmarks test both raw parsing (byte slice → Frame) and command dispatch (Frame → Command) separately
  • value sizes chosen to cover typical cache workloads: 64B (session tokens), 256B (small JSON), 1KB (document fragments), 16KB (larger payloads)

add criterion benchmark suites for the two performance-critical crates:

ember-core (keyspace.rs):
- keyspace_get: HashMap lookup + Bytes clone at 64B/256B/1KB/16KB
- keyspace_set_overwrite: overwrite path with memory tracking
- keyspace_set_with_expiry: TTL bookkeeping overhead
- keyspace_mixed: alternating 50/50 get/set on 10k keys
- memory_entry_size: cost of memory::entry_size() calculation

ember-core (engine.rs):
- engine/route_get: full async path through mpsc + oneshot channels
- engine/route_set_64B: SET through engine routing layer

ember-protocol (protocol.rs):
- resp3_parse: PING, GET, SET at 64B and 1KB
- resp3_serialize: simple, bulk 64B, bulk 1KB
- command_from_frame: GET and SET command dispatch

run with: cargo bench --workspace
@kacy
kacy merged commit 1677de6 into main Feb 7, 2026
4 of 5 checks passed
@kacy
kacy deleted the feat/criterion-benchmarks branch February 7, 2026 20:06
kacy added a commit that referenced this pull request Feb 11, 2026
feat: criterion micro-benchmarks for hot path
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