Skip to content

Commit

Permalink
docs: add note about PYTHONMALLOC for accurate jemalloc memory tracki…
Browse files Browse the repository at this point in the history
…ng (#17709)

Added a note in the documentation suggesting that users may set
`PYTHONMALLOC=malloc` when using `jemalloc`. This allows jemalloc to
track memory usage more accurately by bypassing Python's internal
small-object allocator (`pymalloc`), helping to ensure that
`cache_autotuning` functions as expected.

This doc change aims to provide more clarity for users configuring
jemalloc with Synapse.


Based on:
https://github.com/element-hq/synapse/blob/4ac783549c5bac7a490a715d359f330bb0b1a161/synapse/metrics/jemalloc.py#L198-L201
  • Loading branch information
hensg authored Oct 7, 2024
1 parent d34f827 commit beb7a95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/17709.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add documentation note about PYTHONMALLOC for accurate jemalloc memory tracking. Contributed by @hensg.
2 changes: 2 additions & 0 deletions docs/usage/administration/admin_faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ line to `/etc/default/matrix-synapse`:

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

*Note*: You may need to set `PYTHONMALLOC=malloc` to ensure that `jemalloc` can accurately calculate memory usage. By default, Python uses its internal small-object allocator, which may interfere with jemalloc's ability to track memory consumption correctly. This could prevent the [cache_autotuning](../configuration/config_documentation.md#caches-and-associated-values) feature from functioning as expected, as the Python allocator may not reach the memory threshold set by `max_cache_memory_usage`, thus not triggering the cache eviction process.

This made a significant difference on Python 2.7 - it's unclear how
much of an improvement it provides on Python 3.x.

Expand Down

0 comments on commit beb7a95

Please sign in to comment.