fix(memory): use jemalloc and report heap statistics #161
No reviewers
Labels
No labels
blocked
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
waiting-on-julian
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jlxq0/matrix-mcp!161
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/jemalloc-allocator"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What changes
tikv-jemalloc-ctl; this crate forbidsunsafe, so themalloc_confexport isn't available.matrix_mcp_heap_bytes{kind=allocated|active|resident|metadata}, read on every scrape.matrix_mcp_client_builds_total{reason=new|replaced}.matrix_mcp_active_clientsis now kept current. It was registered but never set, so it always read 0..cargo/audit.tomlwith three advisories that don't apply, each with its reason.maincurrently failscargo auditon these three as well.Why
v0.10.20 grew about 40 MiB/h on 9 Nov, with 39 tool calls in 10 hours.
/proc/1/mapsshowed 30 glibc arena heaps (64 MiB reservations, 593 MiB committed) for 17 threads. Platform #1496 runsMALLOC_ARENA_MAX=2as a parallel experiment. Either way, the heap gauges show retention (allocatedrising) apart from allocator overhead (the gap toresident).Gates, run locally with 1.98.0 (the CI toolchain)
fmt --checkpasses.clippy -D warningspasses.cargo auditpasses.cargo deny check bans licenses sourcespasses.heap_stats_come_from_the_live_allocator.🤖 Generated with Claude Code
https://claude.ai/code/session_01E2xQRZnoBbY9SEC5nF6J4U
v0.10.20 still grew about 40 MiB/h on 9 Nov with 39 tool calls in ten hours. Its RSS sat in 30 glibc arena heaps (64 MiB reservations, 593 MiB committed) for 17 threads. jemalloc becomes the global allocator, with background threads purging freed pages. matrix_mcp_heap_bytes{kind} reports jemalloc's allocated, active, resident and metadata bytes on every scrape, so retention and allocator overhead can be told apart. matrix_mcp_client_builds_total{reason} counts client builds. The matrix_mcp_active_clients gauge was never set and is now kept current. .cargo/audit.toml documents three advisories that do not apply to this build: rmcp's OAuth and Streamable HTTP clients are not compiled in, and the bundled SQLite fix needs a matrix-sdk release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2xQRZnoBbY9SEC5nF6J4U