How many cores are used by Github Actions Runners?

2.8k Views Asked by At

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?

3

There are 3 best solutions below

1
Bernard Wiesner On

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.

0
DevHolako On

I have personally tried it and it only has two cores. When running tests, do you use a MySQL database or a SqlLite memory database? I ran about 188 tests with 1024 assertions and it took a maximum of 15 seconds to run with the database refreshed and seeds every time. To achieve this, I used FastRefreshDatabase from plannr/laravel-fast-refresh-database + the --parallel. Perhaps this can be helpful for you too.

0
nicojs On