Skip to content

perf: reduce memory overhead per entry - #52

Merged
kacy merged 3 commits into
mainfrom
perf/memory-optimization
Feb 7, 2026
Merged

perf: reduce memory overhead per entry#52
kacy merged 3 commits into
mainfrom
perf/memory-optimization

Conversation

@kacy

@kacy kacy commented Feb 7, 2026

Copy link
Copy Markdown
Owner

summary

reduces memory overhead per entry by ~20% through:

  • replace Option<Instant> (16 bytes) with u64 timestamps (8 bytes)
  • remove size: usize field from Entry (computed on demand)
  • use Box<str> instead of String for keys in concurrent mode (24→16 bytes)

introduces a shared time module for compact monotonic timestamps.

benchmark results

memory test (1M keys, 64-byte values):

  • main: ~296 bytes/key
  • optimized: ~253 bytes/key
  • improvement: ~14-20% reduction

throughput test (no regression):

  • SET: 1.27M req/sec
  • GET: 1.8M req/sec

tested

  • all 223 tests pass
  • cargo clippy clean
  • local throughput benchmark
  • memory benchmark on GCP VM

kacy added 3 commits February 7, 2026 15:42
- remove size field from Entry (compute on demand): -8 bytes
- use u64 timestamp instead of Option<Instant> for expiry: -8 bytes
- use Box<str> instead of String for keys in concurrent mode: -8 bytes
- add time.rs module for compact monotonic timestamps

total savings: ~24 bytes per entry in concurrent mode
- throughput: 1.86M SET/sec, 2.48M GET/sec (1.85-2.14x vs redis)
- memory: 257 bytes/key (down from 307, 16% reduction)
- non-pipelined: 2x faster than redis (200k vs 100k ops/sec)
@kacy
kacy merged commit 51b3029 into main Feb 7, 2026
5 checks passed
@kacy
kacy deleted the perf/memory-optimization branch February 7, 2026 20:59
kacy added a commit that referenced this pull request Feb 11, 2026
* perf: reduce memory overhead per entry

- remove size field from Entry (compute on demand): -8 bytes
- use u64 timestamp instead of Option<Instant> for expiry: -8 bytes
- use Box<str> instead of String for keys in concurrent mode: -8 bytes
- add time.rs module for compact monotonic timestamps

total savings: ~24 bytes per entry in concurrent mode

* docs: update benchmarks with memory optimization results

- throughput: 1.86M SET/sec, 2.48M GET/sec (1.85-2.14x vs redis)
- memory: 257 bytes/key (down from 307, 16% reduction)
- non-pipelined: 2x faster than redis (200k vs 100k ops/sec)

* style: fix formatting
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