A few simple tricks to tune your github actions runtime
Github actions are a nice thing, spin up your preferred operating system and execute some tests. While implementing them in one of my projects, i had to trial and error and: waiting for the tests to complete is an annoying situation!
ubuntu-latest image and installing several software components, two
lines catched my eyes while waiting for the packages to install:
The reason for these log messages is quite simple. If you install any package
ubuntu-latest, it detects added manpages and altered system settings that
need to be applied to the systems initramfs.
Re-computing the initramfs is a quite cpu and storage intensive operation and it comes with some real time penalty! Updating the manpages database too.
So why do it if you spin up just a throwaway machine? Lets disable these triggers with two simple commands in your github workflow:
and save some time! Look at the durations of this example repository:
Tuned workflow script in this repository disables various trigger
actions, such as
mime and others.
During package installation,
dpkg attempts to call the filesystem sync()
operation to ensure save I/O operations. This can also be disabled by enabling
force-unsafe-io option in
Using all these simple tricks saves up to ~40 seconds in this example, depending on how many packages you install (for man-db) and if you install different packages in multiple stages, you might save even more time.
You can include this action into your projects yml files with the github
using flag, see this example repository
Have a look at the general Dpkg-Triggers documentation, there are more time savers to disable ..
Another option is to use the github caching
for other dependencies you install via third party package managers (npm, etc)
to speedup your runtime (Note: This makes sense with small components, not big
package dependencies, as you might easily exceed the maximum allowed cache size