Skip to content

Preload downstream_pipeline in CommitStatusPreloader

What does this MR do and why?

This fixes an N+1 for the commit status dropdown in places such as the stages controller, which is used to display a list of jobs on pipelines.

The additional preloads are needed for policy checks and path rendering. In order to make this work, we also had to extend CommitStatusPreloader with support for nested associations.

The change is behind the feature flag preload_ci_bridge_downstream_pipelines, disabled by default.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Comment Before After
Observe the difference in query count in the upper left corner. Note that stage.json is selected in the upper-right corner dropdown. Screenshot_2024-01-18_at_16.06.58 Screenshot_2024-01-18_at_16.08.34
Observe the difference in runtime and flamegraph shape Screenshot_2024-01-18_at_16.30.43 Screenshot_2024-01-18_at_16.29.15

How to set up and validate locally

In a project, create a pipeline with lots of child pipelines in a single stage. Then, with the flag preload_ci_bridge_downstream_pipelines disabled and enabled:

  1. On the pipelines page, click the stage for the pipeline to trigger the load
  2. Once the stages have loaded, pick the corresponding stages.json entry in the upper right corner of the performance bar
  3. Make note of the query count

When disabled, the query count should be quite high. When enabled, it should be significantly lower. To ensure the test is fair, make sure the requests are not being cached.

For chrome, this can be done by checking "Disable cache" for webtools network page

Edited by Hordur Freyr Yngvason

Merge request reports