Hello.
I just wanted to migrate my server’s base docker images from 22.04 to 24.04. but before that, I just run some performance tests and I got strange results.
My host is a laptop installed with ubuntu 24.04; docker, qemu, etc. up to date.
I run this simple python script:
#!/usr/bin/env python3
from pathlib import Path
from subprocess import run
from time import perf_counter
here = Path(__file__).parent
platforms = ["arm64", "amd64"]
revisions = ["22.04","22.10","23.04","23.10", "24.04","24.10",]
results = {}
for plat in platforms:
for rev in revisions:
print(f"Testing on ubuntu:{plat}-{rev}")
cmd = f"docker run -u 0 --platform=linux/{plat} --rm -v {here}/test.sh:/test.sh:ro ubuntu:{rev} /test.sh"
tic = perf_counter()
run(cmd, shell=True)
toc = perf_counter()
results[f"{rev}_{plat}"] = toc-tic
print("Results:")
for who, res in results.items():
print(f"Result for {who} : {res:0.4f} seconds")
with the test.sh script here:
echo -n "testing... "
for i in $(seq 2 10000); do
is_prime=1
j=2
while ((j*j <= i)); do
if (( i % j == 0)); then
is_prime=0
break
fi
((j++))
done
if (( is_prime == 1 )); then
echo $i > /dev/null
fi
done
echo "done"
all it does it just compute the prime numbers below 10000.
The python scrit execute that on all ubuntu version from 22.04 to 24.10 in both amd64 and arm64.
the result is:
Result for 22.04_arm64 : 5.6774 seconds
Result for 22.10_arm64 : 4.9346 seconds
Result for 23.04_arm64 : 4.4524 seconds
Result for 23.10_arm64 : 4.7802 seconds
Result for 24.04_arm64 : 36.6181 seconds
Result for 24.10_arm64 : 36.5947 seconds
Result for 22.04_amd64 : 2.7099 seconds
Result for 22.10_amd64 : 2.3456 seconds
Result for 23.04_amd64 : 2.7159 seconds
Result for 23.10_amd64 : 2.4836 seconds
Result for 24.04_amd64 : 2.0073 seconds
Result for 24.10_amd64 : 2.6205 seconds
The overhead for arm64 is normal due to emulation. but it got very strange starting from version 24.04 almost 9 times slower than 23.10 !!! and the same with 24.10.
I try several times to re-run but got always similar results.
does anyone ever see this before? am I missing something? do you have a workaround ?
I can reproduce this on my ThinkPad Z13 running Ubuntu 24.04.
Results:
Result for 22.04_arm64 : 5.0317 seconds
Result for 22.10_arm64 : 5.2264 seconds
Result for 23.04_arm64 : 6.2018 seconds
Result for 23.10_arm64 : 5.9245 seconds
Result for 24.04_arm64 : 30.2712 seconds
Result for 24.10_arm64 : 30.1900 seconds
Result for 22.04_amd64 : 1.9444 seconds
Result for 22.10_amd64 : 1.9076 seconds
Result for 23.04_amd64 : 1.9498 seconds
Result for 23.10_amd64 : 1.8836 seconds
Result for 24.04_amd64 : 1.8904 seconds
Result for 24.10_amd64 : 1.8787 seconds
Given all you’re doing is spinning up the container and using shell internals, I wondered if it might be a shell issue. So I changed your test.sh to run a simple line of perl to count to a large number perl -e 'for($i=0;$i<1e8;$i++) { }'.
On the bare metal on the ThinkPad, it takes about 2.7 seconds to run that perl command alone.
Using your script, on my ThinkPad Z13 it takes:
Results:
Result for 22.04_arm64 : 23.7569 seconds
Result for 22.10_arm64 : 23.4429 seconds
Result for 23.04_arm64 : 24.5408 seconds
Result for 23.10_arm64 : 502.0283 seconds
Result for 24.04_arm64 : 507.7108 seconds
Result for 24.10_arm64 : 501.1219 seconds
Result for 22.04_amd64 : 4.1976 seconds
Result for 22.10_amd64 : 4.0933 seconds
Result for 23.04_amd64 : 4.3692 seconds
Result for 23.10_amd64 : 4.1189 seconds
Result for 24.04_amd64 : 4.2814 seconds
Result for 24.10_amd64 : 4.3990 seconds
Ok, so it’s not just bash! Something weird is going on with those 23.10, 24.04 and 24.10 arm64 images.
Interestingly, on my work MacOS MacBook Pro with an M3 CPU (and Rosetta 2 installed), it’s less affected, it seems. But still slower on some of the images.
Result for 22.04_arm64 : 0.4131 seconds
Result for 22.10_arm64 : 0.4410 seconds
Result for 23.04_arm64 : 1.3784 seconds
Result for 23.10_arm64 : 1.4367 seconds
Result for 24.04_arm64 : 1.3412 seconds
Result for 24.10_arm64 : 1.3434 seconds
Result for 22.04_amd64 : 1.5206 seconds
Result for 22.10_amd64 : 1.4907 seconds
Result for 23.04_amd64 : 1.5083 seconds
Result for 23.10_amd64 : 1.5068 seconds
Result for 24.04_amd64 : 1.5827 seconds
Result for 24.10_amd64 : 1.5370 seconds
The mac is less affected, maybe because it is already an arm64 and then need to emulate the amd64 architecture, while my computer is on amd64 and need to emulate the arm64…
I tried on my raspberry Pi (so: arch architecture) that is with ubuntu 24.04 too (with fewer prime to search because the cpu is slow (<5000))
and… the result are
Results:
Result for 22.04_arm64 : 3.3425 seconds
Result for 22.10_arm64 : 3.2845 seconds
Result for 23.04_arm64 : 3.2001 seconds
Result for 23.10_arm64 : 3.1686 seconds
Result for 24.04_arm64 : 3.1912 seconds
Result for 24.10_arm64 : 3.2585 seconds
Result for 22.04_amd64 : 10.6232 seconds
Result for 22.10_amd64 : 10.2351 seconds
Result for 23.04_amd64 : 9.5263 seconds
Result for 23.10_amd64 : 9.3390 seconds
Result for 24.04_amd64 : 10.0090 seconds
Result for 24.10_amd64 : 9.9589 seconds
exactly the expected behavior slower on emulated arch, but homogeneous…