Run process with higher priority on macOS when installed as a service
Problem to solve
MacOS 12.2.1
Gitlab-runner 14.10
When running gitlab-runner via launchctl (~/Library/LaunchAgents/...gitlab-runner.plist) not getting full process/resource available. Jobs are running slow compared to running via terminal or ssh.
Command performance (minutes:seconds)
- macOS GUI terminal session - 5:48
- SSH session - 5:35
- GitLab Runner - 36:42
Add below code to plist file. Select the value that matches your needs. See man page URL reference at bottom.
<key>ProcessType</key>
<string>Interactive</string>
Command performance (minutes:seconds)
- macOS GUI terminal session - 5:48
- SSH session - 5:35
- GitLab Runner - 5:48
Further details
Proposal
Doc https://docs.gitlab.com/runner/install/osx.html
Need to add a note that when using launchctl to check this code is present in plist file if you want full process/resource available.
<key>ProcessType</key>
<string>Interactive</string>
Who can address the issue
Other links/references
https://www.manpagez.com/man/5/launchd.plist
ProcessType <string>
This optional key describes, at a high level, the intended purpose of the
job. The system will apply resource limits based on what kind of job it
is. If left unspecified, the system will apply light resource limits to
the job, throttling its CPU usage and I/O bandwidth. The following are
valid values:
Background
Background jobs are generally processes that do work that was not
directly requested by the user. The resource limits applied to
Background jobs are intended to prevent them from disrupting the
user experience.
Standard
Standard jobs are equivalent to no ProcessType being set.
Adaptive
Adaptive jobs move between the Background and Interactive classifi-
cations based on activity over XPC connections. See
xpc_transaction_begin(3) for details.
Interactive
Interactive jobs run with the same resource limitations as apps,
that is to say, none. Interactive jobs are critical to maintaining
a responsive user experience, and this key should only be used if
an app's ability to be responsive depends on it, and cannot be made
Adaptive.
Edited by Elliot Rushton