Skip to content

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.

  1. Create a project
  2. Create 30 secret project-level variables
  3. 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
  1. Create 20 pipelines
  2. Visit pipelines.json in Pipeline index page or MR page

Screenshot_from_2019-02-01_16-46-25

12.41 sec to render the results

What's the outcome of this fix

Screenshot_from_2019-02-01_16-35-17

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?

Edited by Shinya Maeda

Merge request reports