From 894a81101ab9f82c065cee33d70a512c6acfffcb Mon Sep 17 00:00:00 2001 From: Henrique Goulart Date: Fri, 13 Sep 2024 16:54:27 -0300 Subject: [PATCH 1/2] docs: add note about PYTHONMALLOC for accurate jemalloc memory tracking 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. --- changelog.d/17709.doc | 2 ++ docs/usage/administration/admin_faq.md | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 changelog.d/17709.doc diff --git a/changelog.d/17709.doc b/changelog.d/17709.doc new file mode 100644 index 00000000000..0c4514c6769 --- /dev/null +++ b/changelog.d/17709.doc @@ -0,0 +1,2 @@ +Add documentation note about PYTHONMALLOC for accurate jemalloc memory tracking +Contributed by @hensg. diff --git a/docs/usage/administration/admin_faq.md b/docs/usage/administration/admin_faq.md index a1184d03759..0dce3d3e37b 100644 --- a/docs/usage/administration/admin_faq.md +++ b/docs/usage/administration/admin_faq.md @@ -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. From 8415f2e77fd44ad93c17df9cef0e6aeabb271866 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 7 Oct 2024 09:27:58 +0100 Subject: [PATCH 2/2] Update changelog.d/17709.doc --- changelog.d/17709.doc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/changelog.d/17709.doc b/changelog.d/17709.doc index 0c4514c6769..8fffc1ca0c3 100644 --- a/changelog.d/17709.doc +++ b/changelog.d/17709.doc @@ -1,2 +1 @@ -Add documentation note about PYTHONMALLOC for accurate jemalloc memory tracking -Contributed by @hensg. +Add documentation note about PYTHONMALLOC for accurate jemalloc memory tracking. Contributed by @hensg.