Exclude build dependency calculation when creating the pipeline
What does this MR do?
In this MR, we exclude the build dependency calculation when creating a pipeline. This will help us to reduce the number of SQL queries when creating a pipeline.
Related to #326475 (closed)
How does it help pipeline creation performance?
In the step of Gitlab::Ci::Pipeline::Chain::Seed
, the method scoped_variables
is called for every job. The method scoped_variables
depends on dependency_variables
.
variables.concat(dependency_variables) if dependencies
Call trace:
- https://gitlab.com/gitlab-org/gitlab/-/blob/12393cb8f3fdb07acd1fe626dd8366bd5ca4338d/lib/gitlab/ci/pipeline/chain/seed.rb#L45
- https://gitlab.com/gitlab-org/gitlab/-/blob/12393cb8f3fdb07acd1fe626dd8366bd5ca4338d/lib/gitlab/ci/pipeline/seed/pipeline.rb#L40
- https://gitlab.com/gitlab-org/gitlab/-/blob/12393cb8f3fdb07acd1fe626dd8366bd5ca4338d/lib/gitlab/ci/pipeline/seed/stage.rb#L19-21
- https://gitlab.com/gitlab-org/gitlab/-/blob/12393cb8f3fdb07acd1fe626dd8366bd5ca4338d/lib/gitlab/ci/pipeline/seed/build.rb#L163-167
- https://gitlab.com/gitlab-org/gitlab/-/blob/12393cb8f3fdb07acd1fe626dd8366bd5ca4338d/lib/gitlab/ci/build/context/build.rb#L24
Screenshots (strongly suggested)
We had these queries;
Ci::Build Load (0.5ms) SELECT "ci_builds".* FROM "ci_builds" WHERE "ci_builds"."type" = 'Ci::Build' AND "ci_builds"."commit_id" IS NULL AND ("ci_builds"."retried" = FALSE OR "ci_builds"."retried" IS NULL) AND (stage_idx < 1)
Ci::Build Load (0.8ms) SELECT "ci_builds".* FROM "ci_builds" WHERE "ci_builds"."type" = 'Ci::Build' AND "ci_builds"."commit_id" IS NULL AND ("ci_builds"."retried" = FALSE OR "ci_builds"."retried" IS NULL) AND (stage_idx < 1)
Ci::Build Load (0.6ms) SELECT "ci_builds".* FROM "ci_builds" WHERE "ci_builds"."type" = 'Ci::Build' AND "ci_builds"."commit_id" IS NULL AND ("ci_builds"."retried" = FALSE OR "ci_builds"."retried" IS NULL) AND (stage_idx < 2)
Ci::Build Load (0.6ms) SELECT "ci_builds".* FROM "ci_builds" WHERE "ci_builds"."type" = 'Ci::Build' AND "ci_builds"."commit_id" IS NULL AND ("ci_builds"."retried" = FALSE OR "ci_builds"."retried" IS NULL) AND (stage_idx < 3)
Ci::Build Load (0.6ms) SELECT "ci_builds".* FROM "ci_builds" WHERE "ci_builds"."type" = 'Ci::Build' AND "ci_builds"."commit_id" IS NULL AND ("ci_builds"."retried" = FALSE OR "ci_builds"."retried" IS NULL) AND (stage_idx < 3)
Ci::Build Load (0.7ms) SELECT "ci_builds".* FROM "ci_builds" WHERE "ci_builds"."type" = 'Ci::Build' AND "ci_builds"."commit_id" IS NULL AND ("ci_builds"."retried" = FALSE OR "ci_builds"."retried" IS NULL) AND (stage_idx < 4)
Ci::Build Load (0.7ms) SELECT "ci_builds".* FROM "ci_builds" WHERE "ci_builds"."type" = 'Ci::Build' AND "ci_builds"."commit_id" IS NULL AND ("ci_builds"."retried" = FALSE OR "ci_builds"."retried" IS NULL) AND (stage_idx < 4)
You may notice that we search for "ci_builds"."commit_id" IS NULL
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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
Edited by Furkan Ayhan