summary refs log tree commit diff
diff options
context:
space:
mode:
authorrealtyem <realtyem@gmail.com>2022-10-14 07:29:49 -0500
committerGitHub <noreply@github.com>2022-10-14 13:29:49 +0100
commitc7446906bdd2e30e5e830a77c05ab9a15aece254 (patch)
tree8e85c571f135ebfe278d9d9e0ed13813ed7dfe2e
parentStabilize the threads API. (#14175) (diff)
downloadsynapse-c7446906bdd2e30e5e830a77c05ab9a15aece254.tar.xz
Set LD_PRELOAD to load jemalloc in Dockerfile-workers. (#14182)
-rw-r--r--changelog.d/14182.docker1
-rwxr-xr-xdocker/configure_workers_and_start.py12
2 files changed, 12 insertions, 1 deletions
diff --git a/changelog.d/14182.docker b/changelog.d/14182.docker
new file mode 100644
index 0000000000..a0ce1bce53
--- /dev/null
+++ b/changelog.d/14182.docker
@@ -0,0 +1 @@
+Set LD_PRELOAD to use jemalloc memory allocator in Dockerfile-workers.
diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py
index d708237f69..4d78453418 100755
--- a/docker/configure_workers_and_start.py
+++ b/docker/configure_workers_and_start.py
@@ -39,6 +39,7 @@
 # continue to work if so.
 
 import os
+import platform
 import subprocess
 import sys
 from pathlib import Path
@@ -632,14 +633,23 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
         with open(mark_filepath, "w") as f:
             f.write("")
 
+    # Lifted right out of start.py
+    jemallocpath = "/usr/lib/%s-linux-gnu/libjemalloc.so.2" % (platform.machine(),)
+
+    if os.path.isfile(jemallocpath):
+        environ["LD_PRELOAD"] = jemallocpath
+    else:
+        log("Could not find %s, will not use" % (jemallocpath,))
+
     # Start supervisord, which will start Synapse, all of the configured worker
     # processes, redis, nginx etc. according to the config we created above.
     log("Starting supervisord")
-    os.execl(
+    os.execle(
         "/usr/local/bin/supervisord",
         "supervisord",
         "-c",
         "/etc/supervisor/supervisord.conf",
+        environ,
     )