Skip to content

Improve the performance of viewing deploy keys

Nick Thomas requested to merge 43080-speed-up-deploy-keys into master

What does this MR do?

Deploy keys are very slow. We can easily do thousands of SQL queries to view https://gitlab.com/gitlab-org/gitlab-ce/-/settings/repository -> https://gitlab.com/gitlab-org/gitlab-ce/-/settings/repository https://gitlab.com/gitlab-org/gitlab-ce/-/deploy_keys at the moment.

This MR has the following improvements:

  • Correctly select public deploy keys, fixing a bug where we might select a random other key
  • Use more-efficient SQL queries to look up the list of deploy keys accessible to a user, skipping a pluck step (2x improvement)
  • Eager-load routes alongside projects (5x improvement on top of the 2x improvement)

The current UI isn't very useful, and displays keys and their associated projects in a manner that is both deep and broad. Regardless of how fast we make it, the JSON response that comes out can easily be 10MiB or so, which is a problem all of its own.

In a follow-up issue, we should modify the UI so that we:

  • Only every show deep or broad information, never both on a single page
  • When broad, deploy keys visible to the user are a paginated list
  • When deep, projects associated with a deploy key are a paginated list

In particular, if you have hundreds of projects associated with a single deploy key, it's not a very useful display at the moment.

Does this MR meet the acceptance criteria?

Conformity

Performance and testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #43080 (moved)

Edited by Nick Thomas

Merge request reports