Reduce CPU use for GitLab permissions synching option #23193
Description
Feature request description
Improve efficiency of codehost permissions synching
Is your feature request related to a problem? If so, please describe.
When users are synching Sourcegraph to a self-managed GitLab code host, and enable the synching option in their external service config, the CPU usage for their gitlab instance rises significantly.
This is because code hosts don't expose user permissions to Sourcegraph through their API, so in order to synchronize permissions SG needs to make requests for each user to determine which repos a user has access to, this can generate multiple requests per user due to limits in the number of repos the code host API allows per request "page". These permissions are cached to reduce the number of requests made, but the permissions are also periodically resynced.
"authorization": {
"identityProvider": {
"type": "oauth"
}
}
Below is a grafana chart from Gitlab, detailing the authorization setting being turned off and on and the CPU use going up in relation to this on the Gitlab codehost.
Users also observe Gitlab's puma cluster worker reaching nearly its full CPU allocation
Note this CPU usage remains high well after the initial synching of permissions.