Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit a71a026

Browse files
committed
Use jemalloc by default
1 parent a9bbe3c commit a71a026

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

docker/README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,5 @@ healthcheck:
207207

208208
## Using jemalloc
209209

210-
Jemalloc is embedded in the image and can be used instead of the default allocator
211-
(cf main README for more infos).
212-
213-
To do so you can add this to your `docker run` commands:
214-
215-
```
216-
-e LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
217-
```
210+
Jemalloc is embedded in the image and will be used instead of the default allocator.
211+
You can read about jemalloc by reading the Synapse [README](../README.md)

docker/start.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import codecs
44
import glob
55
import os
6+
import platform
67
import subprocess
78
import sys
8-
99
import jinja2
1010

1111

@@ -213,6 +213,14 @@ def main(args, environ):
213213
if "-m" not in args:
214214
args = ["-m", synapse_worker] + args
215215

216+
217+
jemallocpath = f"/usr/lib/{platform.machine()}-linux-gnu/libjemalloc.so.2"
218+
219+
if os.path.isfile(jemallocpath):
220+
environ['LD_PRELOAD'] = jemallocpath
221+
else:
222+
log(f"Could not find {jemallocpath}, will not use")
223+
216224
# if there are no config files passed to synapse, try adding the default file
217225
if not any(p.startswith("--config-path") or p.startswith("-c") for p in args):
218226
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
@@ -248,9 +256,9 @@ def main(args, environ):
248256
args = ["python"] + args
249257
if ownership is not None:
250258
args = ["gosu", ownership] + args
251-
os.execv("/usr/sbin/gosu", args)
259+
os.execve("/usr/sbin/gosu", args, environ)
252260
else:
253-
os.execv("/usr/local/bin/python", args)
261+
os.execve("/usr/local/bin/python", args, environ)
254262

255263

256264
if __name__ == "__main__":

0 commit comments

Comments
 (0)