The application I build run on both Linux and Windows, and because of this, often my build pipelines consist of jobs on Linux and Windows machines.
By default the builds directory is located on the hard drive. If we do not care about the object files, we can run the build on a RAM disk (tmpfs in Linux) and upload the artefacts.
This reduces HDD load and allows us to build a bit faster.
Download a RAM disk tool. ImDisk works for me. Setup a RAM disk at R:\ and ensure it is big enough to store the git repo as well as the intermediate build objects.
Goto the Gitlab runner location, and edit the config.toml file.
concurrent = 10 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "Windows10" url = "https://gitlab.com" token = "TOKEN" executor = "shell" shell = "powershell" output_limit = 32768 builds_dir = "R:\\GitlabRunner\\builds" [runners.custom_build_dir] enabled = true [runners.cache] [runners.cache.s3] [runners.cache.gcs]
Ensure that the builds_dir points to a location on the R drive and that custom build dir is set to enabled.
It’s also a good idea to set the %TEMP% and %TMP% to the R:/Temp directory, as some linker steps from Microsoft utilise the TEMP folder.
It’s a good idea to run the gitlab runner in a docker file.
Regardless the config.toml is generally located under /srv/gitlab-runner
... [[runners]] name = "devel runner" url = "https://gitlab.com/" token = "TOKEN" executor = "docker" builds_dir = "/ramdisk" cache_dir = "/ramdisk/cache" [runners.custom_build_dir] enabled = true [runners.cache] [runners.cache.s3] [runners.cache.gcs] [runners.docker] tls_verify = false image = "alpine:latest" privileged = true disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/ramdisk:/ramdisk:rw", "/cache:/ramdisk/cache:rw"] shm_size = 0
Similar to the Windows config, add in the builds and cache dir, but also let docker know about the volumes.
Setup a tmpfs of 20Gigabytes by adding a line into the /etc/fstab
tmpfs /ramdisk tmpfs exec,rw,size=20G 0 0
You should be set to build at the speed of RAM and not be limited to HDD access speeds.
Note that all data on the RAM drive is lost after a reboot, so don’t put anything on there that you are not prepared to lose.