Commit 7392f05
committed
Use jemalloc as global allocator
Production lightning nodes were getting OOM-killed during boot.
The bun process running the NAPI-RS native addon hit 857MB RSS
in a 1GB container, leaving no headroom for channel monitor
deserialization at startup.
glibc's malloc fragments heavily under Rust's allocation
patterns (many small, short-lived allocations interleaved with
long-lived ones), inflating RSS 30-50% beyond actual usage.
jemalloc's arena-based allocator and thread-local caching avoid
this fragmentation.
disable_initial_exec_tls is required because NAPI-RS addons are
loaded via dlopen at runtime. Without it, jemalloc's TLS usage
exhausts the static TLS block allocated at program start, since
dlopen'd libraries get a smaller TLS allocation than statically
linked ones.1 parent 2ed4521 commit 7392f05
2 files changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
3 | 9 | | |
4 | 10 | | |
5 | 11 | | |
| |||
0 commit comments