0

I am running php artisan test --parallel on github actions using a docker container, and the performance is worse than if I run it without --parallel. If I specify the cores with php artisan test --parallel --processes=4 it gets even slower.

Does the github actions runner only run on 1 core? Or is there something else to configure to be able to use multiple cores on the runners?

Bernard Wiesner
  • 961
  • 6
  • 14
  • 3
    According to the [github actions official documentation](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources), the runners number of core depends on the runner specified machine. – GuiFalourd Jul 07 '23 at 19:02

1 Answers1

0

Thanks to @GuiFalourd and further research and testing I found out the following.

  • Regular Ubuntu machine in GitHub actions uses only 2 cores.

  • Parallel testing using php artisan test --parallel creates as many test databases as cores the first time it runs and executes the migrations on each one of them. It does this to avoid deadlocks and other issues between concurrent tests. If you have many migrations it could be slower to use parallel testing in a CI pipeline because databases are not persisted between runs and migrations occur on every run for every process.

Solution: You can squash your migrations into a mysql dump, to avoid the time consuming migrations.

Performance benefits with parallel testing using GitHub actions will not be great, since it would only use 2 cores/processes, but it should be faster than without if you avoid the migrations step by squashing them.

Bernard Wiesner
  • 961
  • 6
  • 14