Open ee7 opened 1 year ago
Yes, that is correct.
It looks like https://github.com/exercism/zig-test-runner/commit/b58066f952603c8d20bd61e3f61bba81a47415ec helped. See https://github.com/exercism/zig-test-runner/pull/71#issuecomment-1694737076.
Next I'll try to compile more of the zig stdlib and add it to the image's zig cache. (Edit: that doesn't seem to produce a significant speedup).
I still don't understand why if I locally:
acronym.zig
and its test_acronym.zig
to the directory foo
in the root dir of this repobin/run-in-docker.sh acronym foo foo
it takes about 3 seconds locally on a slow machine (definitely using the container's zig cache), but it takes Exercism about 7-8 seconds to run the tests for acronym
from the online editor. The latter time is roughly how long step 2 takes locally if I comment out the zig cache creation steps in the Dockerfile. So either:
Any ideas?
It must be the container startup time, because https://github.com/exercism/zig-test-runner/actions/runs/5992634417/job/16252228546 indicates a successful deploy, which is I can verify by going to https://exercism.org/maintaining/tracks/zig.
indicates a successful deploy, which is I can verify by going to https://exercism.org/maintaining/tracks/zig.
Yeah, I know about this. But it's possible for bin/run-in-docker.sh acronym foo foo
to be fast locally, but slow in production, without it being entirely due to the production container startup time.
For example, it seemed like https://github.com/exercism/zig-test-runner/commit/b58066f952603c8d20bd61e3f61bba81a47415ec really was a consistent 2x speedup over the immediately preceding state. I believe that Zig builds for the native CPU by default (even in debug mode, with the rationale that otherwise it'd give up performance when running debug builds, which is sometimes important), like passing -march=native
for C. We have to explicitly specify something like -target x86_64-linux-musl
or -mcpu baseline
to assume only the minimum available CPU features.
Locally, the CPU at execution time was the same as the CPU at build time, so Zig could use the image's cache. But that wasn't true for the image that was deployed in production, because the GitHub Actions CPU features in general won't match those of the AWS machine.
So I'm trying to remove other possible differences in production that stop Zig from fully using the image's cache. For example, I noticed that the cache manifest contains inodes, but I haven't checked yet whether that means the cache cannot be used if transferred to another filesystem at the same path, or whether there's an extra cost if you do that. But it's designed to avoid absolute paths, at least.
I'll ask some Zig people if I can't find out myself.
Locally, the CPU at execution time was the same as the CPU at build time, so Zig could use the image's cache. But that wasn't true for the image that was deployed in production, because the GitHub Actions CPU features in general won't match those of the AWS machine.
Is there anything I can run in production that will figure out the right architecture?
Is there anything I can run in production that will figure out the right architecture?
Yes, but:
https://github.com/exercism/zig-test-runner/commit/82b56afe82002cb6342222734b6bdeb8b665734c is a significant speedup for a
RUN zig test foo
command that's added at the bottom of theDockerfile
. But it doesn't seem to be a speedup in production.Some possible short-term ways to improve:
USER
(done in https://github.com/exercism/zig-test-runner/commit/b8b9d0221601474df58fd793d85d5fc5897fd837)bin/run.sh
, notzig test
directly (done in https://github.com/exercism/zig-test-runner/commit/063642036853d548a3daa0fd53ecac53492942a7)-target
(done in https://github.com/exercism/zig-test-runner/commit/b58066f952603c8d20bd61e3f61bba81a47415ec)zig test
tmpfs
.Longer term: