Skip to content

Avoid stubbing a build to evaluate rules

Fabio Pitino requested to merge ci-seed-skip-stubbing-build into master

What does this MR do and why?

Related to #350057

This MR attempts to reduce the time spent in initializing Ci::Build for the purpose of evaluating rules: and variables expansion.

Based on @mbobin profiling below we can see that for each job we build a context to evaluate rules. In this step we spend ~54% building a stub job and 45% calculating scoped_variables. In this MR we are aiming to remove that 54%.

image

Before

We were initializing Ci::Build as part of the evaluation context for rules: (as stub_build) and then again inside to_resource method.

This logic also was wrong because we were also initializing a stub Ci::Build object even for the evaluation context of Ci::Bridge jobs. Ci::Bridge variables could differ from Ci::Build (for example, expanded_environment_name is always nil for bridges and affects the variables.

After

We initialize the processable once and assign most of the attributes immediately. We then reuse the same object in the evaluation context (instead of doing the expensive initialization of a new Ci::Build object). Finally we update the processable object only with what changed after the evaluation of rules.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Fabio Pitino

Merge request reports