From 2b20e1232b6542e780a61e1832e72cc2babc8989 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 1 Aug 2026 20:58:40 +0300 Subject: shuriken CronJob: bound memory + ImageMagick disk spill (OOM fix) The first run OOM-killed (exit 137) on irregular.ninja: Alpine's ImageMagick is Q16-HDRI (32 bytes/pixel), so a 37 MP AI-upscaled PNG decodes to ~1.2 GiB per buffer and -auto-orient doubles it -- well over the 1 Gi pod limit. The image now ships an ImageMagick policy (memory/map 512 MiB, disk 8 GiB) that spills oversized decodes to a disk cache instead of OOMing. Match it here: bump the pod memory limit to 2 Gi for the working set, pin OMP_NUM_THREADS=1 (the build is OpenMP-enabled; extra resample threads only multiply HDRI memory pressure), and add a disk-backed /tmp emptyDir (sizeLimit 8 Gi) for the pixel-cache spill. --- f3s/shuriken/helm-chart/templates/cronjob.yaml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/f3s/shuriken/helm-chart/templates/cronjob.yaml b/f3s/shuriken/helm-chart/templates/cronjob.yaml index ddb97b8..2641ce0 100644 --- a/f3s/shuriken/helm-chart/templates/cronjob.yaml +++ b/f3s/shuriken/helm-chart/templates/cronjob.yaml @@ -65,13 +65,24 @@ spec: # to shuriken as --image-jobs. - name: SHURIKEN_IMAGE_JOBS value: "1" + # ImageMagick 7 is Q16-HDRI and built with OpenMP. Pin OpenMP + # to a single thread: the pod is cpu-limited to 1 core anyway, + # and extra resample threads would only multiply the HDRI pixel + # buffer's memory pressure (the OOM trigger for large PNGs). + - name: OMP_NUM_THREADS + value: "1" resources: requests: cpu: 100m memory: 256Mi limits: cpu: "1" - memory: 1Gi + # 2 Gi: the ImageMagick policy (baked into the image) caps + # the in-RAM pixel cache at 512 MiB and spills oversized + # decodes to the /tmp disk cache, so this headroom covers the + # working set + bash + the HDRI buffers of one photo without + # the pod being OOM-killed on a multi-megapixel source image. + memory: 2Gi securityContext: allowPrivilegeEscalation: false runAsUser: 0 @@ -82,10 +93,17 @@ spec: - name: configs mountPath: /configs readOnly: true + - name: tmp + mountPath: /tmp volumes: - name: data persistentVolumeClaim: claimName: shuriken-data-pvc - name: configs configMap: - name: shuriken-config \ No newline at end of file + name: shuriken-config + # Disk-backed scratch for ImageMagick's disk pixel cache (the + # policy spills oversized HDRI decodes here instead of OOMing). + - name: tmp + emptyDir: + sizeLimit: 8Gi \ No newline at end of file -- cgit v1.2.3