Skip to content

Commit de6a6f1

Browse files
committed
perf(sandbox): reduce memory dirtying from envd logging in journald
Route envd stdout to /dev/null and keep only stderr in journald via the envd systemd service, so envd panics/fatal errors are still inspectable but per-request debug events no longer dirty guest memory and rootfs pages on every snapshot. Full debug logs continue to ship through the HTTP exporter to the orchestrator. Bound the rest of journald with a drop-in: persistent (rootfs-backed) storage capped at 8M with warning-only filtering, so other systemd services can't grow the journal without bound either.
1 parent dbef5ef commit de6a6f1

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

packages/orchestrator/pkg/template/build/core/rootfs/files/envd.service.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Type=simple
1212
Restart=always
1313
User=root
1414
Group=root
15+
# Discard envd stdout (debug logs still ship via the HTTP exporter); only
16+
# stderr (envd panics/fatal errors) reaches journald.
17+
StandardOutput=null
18+
StandardError=journal
1519
Environment=GOTRACEBACK=all
1620
LimitCORE=infinity
1721
ExecStartPre=/bin/sh -c 'mountpoint -q /etc/ssl/certs || (mkdir -p /run/e2b/certs && mount --bind /run/e2b/certs /etc/ssl/certs) && ([ -s /etc/ssl/certs/ca-certificates.crt ] || update-ca-certificates)'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- /*gotype:github.com/e2b-dev/infra/packages/orchestrator/pkg/template/build/core/rootfs.templateModel*/ -}}
2+
{{ .WriteFile "etc/systemd/journald.conf.d/e2b.conf" 0o644 }}
3+
4+
[Journal]
5+
Storage=persistent
6+
SystemMaxUse=8M
7+
SystemMaxFileSize=2M
8+
MaxLevelStore=warning
9+
MaxLevelConsole=warning
10+
MaxLevelKMsg=warning
11+
MaxLevelWall=emerg
12+
ForwardToSyslog=no

packages/orchestrator/pkg/template/build/core/rootfs/rootfs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func TestAdditionalOCILayers(t *testing.T) {
9090

9191
keysIter := maps.Keys(actualFiles)
9292
keys := slices.Collect(keysIter)
93-
assert.Len(t, keys, 13)
93+
assert.Len(t, keys, 14)
9494
assert.Equal(t, "e2b.local", actualFiles["etc/hostname"])
9595
assert.Equal(t, "nameserver 8.8.8.8", actualFiles["etc/resolv.conf"])
9696

0 commit comments

Comments
 (0)