Optimize slow pipelines.js response
What does this MR do?
pipelines.js
is slow on gitlab.com, because it executes deployable_by_user?
for each manual jobs, which contains build.expanded_environment_name
.
build.expanded_environment_name
is an expensive process. It expands all secret variables in order to get a real environment name. However, we changed lifecycle of deployments
in a few months ago, and we can get an environment
association through deployment
today. Using this association effectively resolves this problem - we don't need to expand secret variables anymore.
There are still expanded_environment_name
in somewhere, not only here. We are slowly killing expanded_environment_name
in this issue. But for the quick win for https://gitlab.com/gitlab-org/gitlab-ee/issues/9549, we will use this solution for pipelines.json.
You can check callstack in https://gitlab.com/gitlab-org/gitlab-ee/issues/9549#note_137338143
How to reproduce the slow response
Reproduced on my local environment.
- Create a project
- Create 30 secret project-level variables
- Commit this .gilab-ci.yml, which has 10 manual jobs
job:
script: echo 'a'
when: manual
environment:
name: job_${CI_COMMIT_REF_SLUG}_${CI_NODE_INDEX}
parallel: 10
allow_failure: false
- Create 20 pipelines
- Visit pipelines.json in Pipeline index page or MR page
12.41 sec to render the results
What's the outcome of this fix
12.41 sec to 1.6 sec.
What are the relevant issue numbers?
Close https://gitlab.com/gitlab-org/gitlab-ee/issues/9549 https://gitlab.com/gitlab-org/gitlab-ce/issues/53146
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary - [-] Documentation created/updated via this MR
- [-] Documentation reviewed by technical writer or follow-up review issue created
-
Tests added for this feature/bug - [-] Tested in all supported browsers
-
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides - [-] Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process.
-
EE specific content should be in the top level /ee
folder - [-] For a paid feature, have we considered GitLab.com plans, how it works for groups, and is there a design for promoting it to users who aren't on the correct plan?
-
Backport to CE -
Security reports checked/validated by reviewer