Skip to content

Speed up closing issue extractor lib specs

Peter Leitzen requested to merge pl-spec-closing-issue-extractor-perf into master

What does this MR do?

This MR improves the performance of closing issue extractor lib specs by using let_it_be and before_all.

Related to &3752.

Contributes to https://gitlab.com/gitlab-org/plan/-/issues/145.

Here's the output from test-prof when run with FPROF=1. Note:

  • Total amount of factories created went down from 395 to 15 🚀
  • Total events went down from 18299 to 2191
  • Queries saved: 16108

Before

[TEST PROF INFO] EventProf results for sql.active_record

Total time: 00:25.268 of 00:53.636 (47.11%)
Total events: 18299

Top 5 slowest suites (by time):

Gitlab::ClosingIssueExtractor (./spec/lib/gitlab/closing_issue_extractor_spec.rb:5) – 00:25.268 (18299 / 74) of 00:53.636 (47.11%)



Finished in 59.15 seconds (files took 1.71 seconds to load)
74 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 395
 Total top-level: 242
 Total time: 32.6875s
 Total uniq factories: 7

   total   top-level     total time      time per call      top-level time               name

     150           0        7.0974s            0.0473s             0.0000s          namespace
     149         148       28.1455s            0.1889s            27.9607s            project
      92          92        4.1713s            0.0453s             4.1713s              issue
       1           1        0.0086s            0.0086s             0.0086s            license
       1           1        0.5469s            0.5469s             0.5469s       jira_project
       1           0        0.3628s            0.3628s             0.0000s       jira_service
       1           0        0.0383s            0.0383s             0.0000s  jira_tracker_data

After

[TEST PROF INFO] EventProf results for sql.active_record

Total time: 00:03.029 of 00:08.670 (34.93%)
Total events: 2191

Top 5 slowest suites (by time):

Gitlab::ClosingIssueExtractor (./spec/lib/gitlab/closing_issue_extractor_spec.rb:5) – 00:03.029 (2191 / 74) of 00:08.670 (34.93%)



Finished in 14.35 seconds (files took 1.7 seconds to load)
74 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 15
 Total top-level: 8
 Total time: 1.7320s
 Total uniq factories: 7

   total   top-level     total time      time per call      top-level time               name

       4           0        0.2987s            0.0747s             0.0000s          namespace
       4           4        0.2882s            0.0721s             0.2882s              issue
       3           2        0.9812s            0.3271s             0.7598s            project
       1           1        0.0082s            0.0082s             0.0082s            license
       1           1        0.6758s            0.6758s             0.6758s       jira_project
       1           0        0.4164s            0.4164s             0.0000s       jira_service
       1           0        0.0476s            0.0476s             0.0000s  jira_tracker_data

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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 Peter Leitzen

Merge request reports