Skip to content

perf: add jemalloc as default allocator - #47

Merged
kacy merged 1 commit into
mainfrom
perf/jemalloc-allocator
Feb 7, 2026
Merged

perf: add jemalloc as default allocator#47
kacy merged 1 commit into
mainfrom
perf/jemalloc-allocator

Conversation

@kacy

@kacy kacy commented Feb 7, 2026

Copy link
Copy Markdown
Owner

summary

adds jemalloc as the default memory allocator for ember-server. reduces allocation contention under multi-threaded workloads.

benchmarks (GCP c2-standard-8)

test system allocator jemalloc change
SET (P=16, 8 shards) ~885k req/s ~998k req/s +13%
GET (P=16, 8 shards) ~1,080k req/s ~1,069k req/s ~same

profiling showed ~7.7% CPU time in malloc/cfree with system allocator. jemalloc's per-thread caches reduce this contention.

changes

  • added tikv-jemallocator as optional dependency (enabled by default)
  • added feature flag: --no-default-features disables jemalloc for platforms that don't support it

test plan

  • benchmarked on GCP VM with redis-benchmark
  • verified server starts correctly with jemalloc enabled
  • verified build works with --no-default-features

design notes

the multi-core scaling issue persists (8 shards ≈ 1 shard performance). jemalloc addresses allocation contention but the main bottleneck is channel overhead (futex operations) from cross-thread request routing. addressing that requires architectural changes (connection affinity or sharded acceptors).

reduces allocation contention under multi-threaded workloads.
profiling showed ~7.7% CPU time spent in malloc/cfree with system
allocator. jemalloc uses per-thread caches to minimize contention.

enabled by default via feature flag. can be disabled with
--no-default-features for platforms that don't support jemalloc.
@kacy
kacy merged commit 7600a38 into main Feb 7, 2026
5 checks passed
@kacy
kacy deleted the perf/jemalloc-allocator branch February 7, 2026 20:06
kacy added a commit that referenced this pull request Feb 11, 2026
perf: add jemalloc as default allocator
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