authoravatarclover caruso<git@paperclover.net>2026-10-23 18:14:26-07:00
committeravatarclover caruso<git@paperclover.net>2026-10-24 19:01:23-07:00
log98cae3f5303586df4613ce13f6456f86e5a12bf6
tree233249cd5a7688636b650974b74a1a57ee4e5fd6
parentab54eeca0df96c59724bf78d5491bfe87b1a677d
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Keep the Knife server and its database responsive under load

The container's 12-core quota ran out every period, freezing the Knife server with the builds, and reclaim had shrunk the ARC to 6 GiB, so its state database was read from the HDDs on the main thread. Assisted-by: claude-opus-5.5

3 files changed, 6 insertions(+), 2 deletions(-)

nixos/knife-linux.nix+2-1
...@@ -38,7 +38,8 @@ in...@@ -38,7 +38,8 @@ in
38 run "run --rm --replace --name=knife-linux --pull=never"38 run "run --rm --replace --name=knife-linux --pull=never"
39 "--sdnotify=conmon --cgroups=no-conmon --log-driver=journald --init --hostname=knife-linux"39 "--sdnotify=conmon --cgroups=no-conmon --log-driver=journald --init --hostname=knife-linux"
40 "--user=${uid}:${gid} --umask=0077 --cap-drop=ALL --security-opt=no-new-privileges"40 "--user=${uid}:${gid} --umask=0077 --cap-drop=ALL --security-opt=no-new-privileges"
41 "--memory=32g --cpus=12 --pids-limit=32768 --shm-size=2g --network=podman"41 # A low weight rather than a CPU quota: an exhausted quota freezes the Knife server too.
42 "--memory=32g --cpu-shares=1024 --pids-limit=32768 --shm-size=2g --network=podman"
42 "--volume=${root}/home:/home/clo"43 "--volume=${root}/home:/home/clo"
43 "--volume=${sandbox}:/Volumes/Code"44 "--volume=${sandbox}:/Volumes/Code"
44 "--volume=/opt/studio-project-store/current/bin/jj-real:/usr/local/bin/jj:ro"45 "--volume=/opt/studio-project-store/current/bin/jj-real:/usr/local/bin/jj:ro"
nixos/zfs-read-cache.nix+3
...@@ -6,6 +6,9 @@ let...@@ -6,6 +6,9 @@ let
6 headroom = 32 * 1024 * 1024 * 1024;6 headroom = 32 * 1024 * 1024 * 1024;
7in7in
8{8{
9 # Reclaim pressure otherwise shrinks the ARC to a few GiB with most memory free.
10 boot.kernelParams = [ "zfs.zfs_arc_min=${toString (32 * 1024 * 1024 * 1024)}" ];
11
9 systemd.services.snowglobe-zfs-read-cache = {12 systemd.services.snowglobe-zfs-read-cache = {
10 wantedBy = [ "multi-user.target" ];13 wantedBy = [ "multi-user.target" ];
11 after = [ "zfs-import-${pool}.service" ];14 after = [ "zfs-import-${pool}.service" ];
tools/knife-linux.md+1-1
...@@ -4,7 +4,7 @@...@@ -4,7 +4,7 @@
4agents directly beside ZFS. [knife-linux.nix](../nixos/knife-linux.nix) builds it4agents directly beside ZFS. [knife-linux.nix](../nixos/knife-linux.nix) builds it
5from [knife-linux.Containerfile](../nixos/knife-linux.Containerfile) on each start5from [knife-linux.Containerfile](../nixos/knife-linux.Containerfile) on each start
6and runs it as the `knife-linux` system service: uid 3000 (`clo`), no6and runs it as the `knife-linux` system service: uid 3000 (`clo`), no
7capabilities, 12 CPUs, a 32 GiB memory limit, `/dev/kvm`, and Podman's NAT network.7capabilities, a low CPU weight with no core cap, a 32 GiB memory limit, `/dev/kvm`, and Podman's NAT network.
8Knife listens on container loopback port 3773; devices reach it through the mesh8Knife listens on container loopback port 3773; devices reach it through the mesh
9as `snowglobe` (device `4b85ee48…`). User namespaces work inside, but Podman's9as `snowglobe` (device `4b85ee48…`). User namespaces work inside, but Podman's
10seccomp filter blocks the `chroot` Chromium-based sandboxes need, so Chromium,10seccomp filter blocks the `chroot` Chromium-based sandboxes need, so Chromium,