Fixing preload for disable_manual_and_scheduled_actions

What does this MR do and why?

Fixing preload for disable_manual_and_scheduled_actions

We are no longer preloading manual and scheduled when flag disable_manual_and_scheduled_actions is true

Some users had hundreds of manual jobs in a pipeline which would timeout during preload

This change introduces a new feature flag called stop_preloading_manual_builds_for_pipeline that allows GitLab to optionally skip loading certain pipeline data to improve performance. When the flag is enabled, the system stops preloading manual and scheduled build actions, which are typically used for deployment buttons and scheduled jobs in the pipeline interface.

The main changes include:

  • Adding logic to conditionally skip loading manual and scheduled actions based on the feature flag
  • Deprecating an old method (represent_stages) by making it log an error when the flag is enabled
  • Adding comprehensive tests to ensure the feature works correctly in both enabled and disabled states
  • Creating the feature flag configuration file to control when this optimization is active

This is essentially a performance optimization that reduces the amount of data loaded when viewing pipelines, particularly targeting manual deployment actions and scheduled jobs that may not always be needed immediately when viewing pipeline information.

References

https://gitlab.com/gitlab-com/request-for-help/-/work_items/3843

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. You can test this by creating 500 manual jobs
    project = Project.last
    pipelines = project.all_pipelines
    
    Benchmark.measure do
      PipelineSerializer
        .new(project: project, current_user: User.first)
        .represent(
          pipelines,
          disable_coverage: true,
          disable_failed_builds: true,
          disable_manual_and_scheduled_actions: true,
          disable_stage_actions: true,
          preload: true,
          preload_statuses: false,
          preload_downstream_statuses: false
        )
    end

Running this before the change gives something like

=> #<Benchmark::Tms:0x0000000137e82c30 @cstime=0.0, @cutime=0.0, @label="", @real=17.096702999901026, @stime=0.24555099999999186, @total=16.954333999999974, @utime=16.708782999999983>

After the change it's faster

=> #<Benchmark::Tms:0x0000000146bde4c0 @cstime=0.0, @cutime=0.0, @label="", @real=2.413884999928996, @stime=0.10268400000001066, @total=2.3369559999999865, @utime=2.234271999999976>

MR acceptance checklist

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

Edited by Max Fan

Merge request reports

Loading