PHP scripts are slow to run
I have a relatively simple PHP script with a single Composer dependency as a part of a bigger flow that runs often, and its runtime dominates the entire flow, taking >0.6s to complete.
It appears that Windmill installs the dependency every time it runs, which would be my guess why it takes so long. Is there a way to make Windmill cache it?
8 Replies
Normally it is cached but will let @Hugo respond on that (he is OOTO, will be back tomorrow). Also if you give us reproduction steps with your imports, it's easier for us to investigate
This is a slightly trimmed down version of my script:
I've deployed it as a standalone script and it still takes >0.5s to run each time, and I can see Composer logs in the output on every run
also can you confirm it's slow after having been cached by all workers
for that, verify that one of the run has been on the same worker more than once
I ran it ~20 times and I only have 3 workers, all the runs have consistently taken >0.5s
here are the logs for one of them: https://img.qilin-qilin.ts.net/2024-07-22_08-44-31_JYiaz.webp
the logs appear to be identical on all runs
for context, I am testing this on a self-hosted windmill deployment with the app itself and all the runners running on the same machine/container
I haven't done any complex configuration
I don't seem to be having caching issues with bun/deno scripts
Composer install is run on each run using the composer lockfile which is generated on deployment. We use standard composer caching (cache folder is /tmp/windmill/cache/composer) and you will get speed gain if the package is already in there. You can test that by running
rm -rf /tmp/windmill/cache/composer/files/willdurand
inside the worker containers (which should make the script >2x slower). The script is still "slow" because of the composer install but the packages are cached.
Bun caching is better optimized and allows us to skip bun install. We might consider in the future to do something similar for php/composer (cc @rubenf wdyt?)for sure, depending on how composer work, we can apply the same approach, have a tar containing the symlinks to the cache, and cache that tar based on lockfile hash