1
2
mirror of https://github.com/dali99/nixos-matrix-modules.git synced 2026-03-29 03:44:01 +02:00

Add withJemalloc setting, enable by default

This commit is contained in:
2025-12-24 08:47:14 +09:00
parent 114ca192c1
commit 543b50dcf5
2 changed files with 19 additions and 0 deletions

View File

@@ -70,6 +70,14 @@ in
'';
};
withJemalloc = mkOption {
type = types.bool;
default = true;
description = ''
Whether to preload jemalloc to reduce memory fragmentation and overall usage.
'';
};
dataDir = mkOption {
type = types.path;
default = "/var/lib/matrix-synapse";
@@ -425,6 +433,11 @@ in
partOf = [ "matrix-synapse.target" ];
wantedBy = [ "matrix-synapse.target" ];
environment = lib.optionalAttrs cfg.withJemalloc {
LD_PRELOAD = "${pkgs.jemalloc}/lib/libjemalloc.so";
PYTHONMALLOC = "malloc";
};
serviceConfig = {
Type = "notify";
User = "matrix-synapse";

View File

@@ -374,6 +374,12 @@ in {
wantedBy = [ "matrix-synapse.target" ];
after = [ "matrix-synapse.service" ];
requires = [ "matrix-synapse.service" ];
environment = lib.optionalAttrs cfg.withJemalloc {
LD_PRELOAD = "${pkgs.jemalloc}/lib/libjemalloc.so";
PYTHONMALLOC = "malloc";
};
serviceConfig = {
Type = "notify";
User = "matrix-synapse";