MacOS: LaunchAgent does not set correct agent priority causing long compilation times
Summary
This has been reported to us by a customer.
We are experiencing slower IOS build on MacOs runners that are run inside jobs. The Runner is installed according to the manual. We tried using benchmark project to compare compilation times: https://github.com/devMEremenko/XcodeBenchmark
Local build with gitlab-runner exec: [245.390 sec]
Local build spawned without runner - [233.759 sec]
Build inside gitlab job: [328.795 sec]
And the customer has found the cause of the issue:
gitlab-runner install setups runner as launchAgent but it doesn't write correct settings for Agent priority. It should add the following parameters to ~/Library/LaunchAgent/gitlab-runner.plist
The parameters are:
<key>LowPriorityBackgroundIO</key><false/>
<key>LowPriorityIO</key><false/>
<key>ProcessType</key><string>Interactive</string>
TeamCity agents do these by default thats why teamcity build were much faster.
Steps to reproduce
Install gitlab-runner to MacOS and benchmark with https://github.com/devMEremenko/XcodeBenchmark.
Compare with a local build, as well as a build using gitlab-runner exec.
Actual behavior
The code takes longer to compile when gitlab-runner is running as a service.
Expected behavior
The code should take the same amount of time to compile.
Relevant logs and/or screenshots
Environment description
MacOS installs that use the LaunchAgent
Used GitLab Runner version
Possible fixes
My understanding is that we use the Kardianos package to create the daemon service and that the plist file is generated here: https://gitlab.com/gitlab-org/gitlab-runner/-/blob/master/vendor/github.com/kardianos/service/service_darwin.go#L262-297.
So if we add the parameters from above into this template it should work.
I would submit the merge request directly but I run Linux and have no way to test the changes so I'm adding the support team contributions label to see if someone else on the team would like to submit the MR.