docker: use less RAM at runtime

compile to bytecode so cpython doesn't have to keep it in memory

ram usage reduced by:
* min: 5.4 MiB (32.6 to 27.2)
* ac/im: 5.2 MiB (39.0 to 33.8)
* dj/iv: 10.6 MiB (67.3 to 56.7)

startup time reduced from:
* min: 1.3s to 0.6s
* ac/im: 1.6s to 0.9s
* dj/iv: 2.0s to 1.1s

image size increased by 4 MiB (min), 6 MiB (ac/im/iv), 9 MiB (dj)

ram usage measured on idle with:
while true; do ps aux | grep -E 'R[S]S|no[-]crt'; read -n1; echo; done

startup time measured with:
time podman run --rm -it localhost/copyparty-min-amd64 --exit=idx
This commit is contained in:
ed 2024-08-02 22:11:23 +00:00
parent ebb1981803
commit 98ffaadf52
11 changed files with 99 additions and 59 deletions

View file

@ -6,6 +6,8 @@ set -e
exit 1
}
suf=-b1
suf=
sarchs="386 amd64 arm/v7 arm64/v8 ppc64le s390x"
archs="amd64 arm s390x 386 arm64 ppc64le"
imgs="dj iv min im ac"
@ -103,11 +105,12 @@ filt=
# --pull=never does nothing at all btw
(set -x
$nice podman build \
--squash \
--pull=never \
--from localhost/alpine-$a \
-t copyparty-$i-$a \
-t copyparty-$i-$a$suf \
-f Dockerfile.$i . ||
(echo $? $i-$a >> err)
(echo $? $i-$a >> err; printf '%096d\n' $(seq 1 42))
rm -f .blk
) 2> >(tee $a.err | sed "s/^/$aa:/" >&2) > >(tee $a.out | sed "s/^/$aa:/") &
done
@ -134,9 +137,10 @@ filt=
variants=
for a in $archs; do
[[ " ${ngs[*]} " =~ " $i-$a " ]] && continue
variants="$variants containers-storage:localhost/copyparty-$i-$a"
variants="$variants containers-storage:localhost/copyparty-$i-$a$suf"
done
podman manifest create copyparty-$i $variants
podman manifest rm copyparty-$i$suf || echo "(that's fine btw)"
podman manifest create copyparty-$i$suf $variants
done
}