Heap usage of shepherd on berlin gathered roughly at T0 (a few hours after booting), T0+8h, an T0+10h:
--8<---------------cut here---------------start------------->8--- ludo@berlin ~$ sudo herd eval root '(gc-stats)' Evaluating user expression (gc-stats). ((gc-time-taken . 36730013844) (heap-size . 31494144) (heap-free-size . 8339456) (heap-total-allocated . 1198237472) (heap-allocated-since-gc . 7581824) (protected-objects . 0) (gc-times . 157)) ludo@berlin ~$ sudo cat /proc/1/maps |grep -A10 heap 016fe000-01810000 rw-p 00000000 00:00 0 [heap] 7f78a387d000-7f78a4000000 rw-p 00000000 00:00 0 7f78a4000000-7f78a4021000 rw-p 00000000 00:00 0 7f78a4021000-7f78a8000000 ---p 00000000 00:00 0 7f78a81d0000-7f78a8600000 rw-p 00000000 00:00 0 7f78a8600000-7f78a8640000 rwxp 00000000 00:00 0 7f78a8640000-7f78a8700000 rw-p 00000000 00:00 0 7f78a8700000-7f78a8740000 rwxp 00000000 00:00 0 7f78a8740000-7f78a8c6c000 rw-p 00000000 00:00 0 7f78a8c6c000-7f78a8cac000 rwxp 00000000 00:00 0 7f78a8cac000-7f78a8ccc000 r--p 00000000 00:17 167921 /gnu/store/9nb1nplyx4gx5pdrmmidngir9jmrzxi3-guile-netlink-1.1.1/lib/guile/3.0/site-ccache/ip/route.go ludo@berlin ~$ sudo herd eval root '(gc-stats)' Password: Evaluating user expression (gc-stats). ((gc-time-taken . 2698835942232) (heap-size . 322998272) (heap-free-size . 56537088) (heap-total-allocated . 49605825968) (heap-allocated-since-gc . 67360208) (protected-objects . 0) (gc-times . 1356)) ludo@berlin ~$ sudo cat /proc/1/maps |grep -A12 heap 016fe000-01810000 rw-p 00000000 00:00 0 [heap] 7f788ce8d000-7f78a1bdd000 rw-p 00000000 00:00 0 7f78a1bdd000-7f78a1c1d000 rwxp 00000000 00:00 0 7f78a1c1d000-7f78a4000000 rw-p 00000000 00:00 0 7f78a4000000-7f78a4021000 rw-p 00000000 00:00 0 7f78a4021000-7f78a8000000 ---p 00000000 00:00 0 7f78a8000000-7f78a8600000 rw-p 00000000 00:00 0 7f78a8600000-7f78a8640000 rwxp 00000000 00:00 0 7f78a8640000-7f78a8700000 rw-p 00000000 00:00 0 7f78a8700000-7f78a8740000 rwxp 00000000 00:00 0 7f78a8740000-7f78a8c6c000 rw-p 00000000 00:00 0 7f78a8c6c000-7f78a8cac000 rwxp 00000000 00:00 0 7f78a8cac000-7f78a8ccc000 r--p 00000000 00:17 167921 /gnu/store/9nb1nplyx4gx5pdrmmidngir9jmrzxi3-guile-netlink-1.1.1/lib/guile/3.0/site-ccache/ip/route.go ludo@berlin ~$ sudo herd eval root '(gc-stats)' Password: Evaluating user expression (gc-stats). ((gc-time-taken . 2909168084878) (heap-size . 348164096) (heap-free-size . 51949568) (heap-total-allocated . 53131500656) (heap-allocated-since-gc . 94062880) (protected-objects . 0) (gc-times . 1383)) ludo@berlin ~$ sudo cat /proc/1/maps |grep -A12 heap 016fe000-01810000 rw-p 00000000 00:00 0 [heap] 7f788b4bd000-7f78a1bdd000 rw-p 00000000 00:00 0 7f78a1bdd000-7f78a1c1d000 rwxp 00000000 00:00 0 7f78a1c1d000-7f78a4000000 rw-p 00000000 00:00 0 7f78a4000000-7f78a4021000 rw-p 00000000 00:00 0 7f78a4021000-7f78a8000000 ---p 00000000 00:00 0 7f78a8000000-7f78a8600000 rw-p 00000000 00:00 0 7f78a8600000-7f78a8640000 rwxp 00000000 00:00 0 7f78a8640000-7f78a8700000 rw-p 00000000 00:00 0 7f78a8700000-7f78a8740000 rwxp 00000000 00:00 0 7f78a8740000-7f78a8c6c000 rw-p 00000000 00:00 0 7f78a8c6c000-7f78a8cac000 rwxp 00000000 00:00 0 7f78a8cac000-7f78a8ccc000 r--p 00000000 00:17 167921 /gnu/store/9nb1nplyx4gx5pdrmmidngir9jmrzxi3-guile-netlink-1.1.1/lib/guile/3.0/site-ccache/ip/route.go --8<---------------cut here---------------end--------------->8--- Heap keeps increasing, and quite quickly. That includes code arenas allocated for JIT (the “rwx” mappings), but the biggest part seems to be the rest of the heap (in particular the second mapping on the second and third samples). During that time shepherd is mostly receiving and logging messages from ‘guix publish’, and occasionally accepting a connection on port 22 and spawning ‘sshd’: --8<---------------cut here---------------start------------->8--- ludo@berlin ~$ sudo strace -p1 -Tt strace: Process 1 attached 10:33:59 rt_sigprocmask(SIG_BLOCK, NULL, [HUP INT TERM CHLD], 8) = 0 <0.000009> 10:33:59 epoll_wait(13, [{events=EPOLLIN, data={u32=50, u64=50}}], 8, -1) = 1 <0.925330> 10:34:00 read(50, "GET /nar/lzip/z0l3fp12ck539qkzc2"..., 4096) = 76 <0.000012> 10:34:00 newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0444, st_size=2298, ...}, 0) = 0 <0.000012> 10:34:00 write(51, "2022-10-20 10:34:00 GET /nar/lzi"..., 96) = 96 <0.000036> 10:34:00 read(50, 0x7f78a88d8020, 4096) = -1 EAGAIN (Resource temporarily unavailable) <0.000008> 10:34:00 epoll_ctl(13, EPOLL_CTL_MOD, 50, {events=EPOLLIN|EPOLLRDHUP|EPOLLONESHOT, data={u32=50, u64=50}}) = 0 <0.000009> 10:34:00 rt_sigprocmask(SIG_BLOCK, NULL, [HUP INT TERM CHLD], 8) = 0 <0.000007> 10:34:00 epoll_wait(13, [{events=EPOLLIN, data={u32=50, u64=50}}], 8, -1) = 1 <0.001968> 10:34:00 read(50, "GET /x2ii2b9zwxnaf020zinccckl2bh"..., 4096) = 46 <0.000010> 10:34:00 newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0444, st_size=2298, ...}, 0) = 0 <0.000012> 10:34:00 write(51, "2022-10-20 10:34:00 GET /x2ii2b9"..., 66) = 66 <0.000019> 10:34:00 read(50, 0x7f78a88d8020, 4096) = -1 EAGAIN (Resource temporarily unavailable) <0.000007> 10:34:00 epoll_ctl(13, EPOLL_CTL_MOD, 50, {events=EPOLLIN|EPOLLRDHUP|EPOLLONESHOT, data={u32=50, u64=50}}) = 0 <0.000008> 10:34:00 rt_sigprocmask(SIG_BLOCK, NULL, [HUP INT TERM CHLD], 8) = 0 <0.000007> 10:34:00 epoll_wait(13, [{events=EPOLLIN, data={u32=50, u64=50}}], 8, -1) = 1 <0.097714> 10:34:00 read(50, "GET /lclbcq0jds63zal1p55g6v0mwz9"..., 4096) = 46 <0.000009> 10:34:00 newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0444, st_size=2298, ...}, 0) = 0 <0.000011> 10:34:00 write(51, "2022-10-20 10:34:00 GET /lclbcq0"..., 66) = 66 <0.000018> 10:34:00 read(50, 0x7f78a88d8020, 4096) = -1 EAGAIN (Resource temporarily unavailable) <0.000009> 10:34:00 epoll_ctl(13, EPOLL_CTL_MOD, 50, {events=EPOLLIN|EPOLLRDHUP|EPOLLONESHOT, data={u32=50, u64=50}}) = 0 <0.000011> --8<---------------cut here---------------end--------------->8--- Logging as performed by ‘%service-file-logger’ is quite GC-intensive (but shouldn’t be leaky!); this bit: (let ((prefix (strftime default-logfile-date-format (localtime (current-time))))) (format output "~a~a~%" prefix line) (loop)) ends up allocating a couple of vectors (for ‘localtime’), a bunch of strings, a string port (via (ice-9 format) it seems), etc. That puts GC under stress. Still, what’s leaking? Why are JIT code arenas being allocated? Ludo’.