Skip to content

Speed up CI retry build service specs

Peter Leitzen requested to merge pl-spec-retry-build-service-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 5453 to 97 🚀
  • Total events went down from 39484 to 6370
  • Queries saved: 33114

Before

[TEST PROF INFO] EventProf results for sql.active_record

Total time: 00:48.079 of 01:47.421 (44.76%)
Total events: 39484

Top 5 slowest suites (by time):

Ci::RetryBuildService (./spec/services/ci/retry_build_service_spec.rb:5) – 00:48.079 (39484 / 161) of 01:47.421 (44.76%)



Finished in 1 minute 54.64 seconds (files took 1.78 seconds to load)
161 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 5453
 Total top-level: 4576
 Total time: 75.5373s
 Total uniq factories: 18

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

    3796        3796       43.8376s            0.0115s            43.8376s    ci_job_artifact
     166         166       26.4417s            0.1593s            26.4417s           ci_build
     163         163        0.9945s            0.0061s             0.9945s    ci_stage_entity
     150         150        0.6742s            0.0045s             0.6742s      ci_build_need
     147           1        6.1103s            0.0416s             0.0760s               user
     146         146        1.9329s            0.0132s             1.9329s  ci_empty_pipeline
     146           0        2.1151s            0.0145s             0.0000s          ci_runner
     146           0        8.2076s            0.0562s             0.0000s ci_trigger_request
     146           0        7.4571s            0.0511s             0.0000s         ci_trigger
     146           0        6.2667s            0.0429s             0.0000s              owner
     146           0        1.1017s            0.0075s             0.0000s  ci_resource_group
     146         146        0.9697s            0.0066s             0.9697s    ci_job_variable
       3           3        0.1254s            0.0418s             0.1254s        ci_pipeline
       2           2        0.0866s            0.0433s             0.0866s          ci_bridge
       1           1        0.0072s            0.0072s             0.0072s            license
       1           1        0.3745s            0.3745s             0.3745s            project
       1           0        0.0388s            0.0388s             0.0000s          namespace
       1           1        0.0170s            0.0170s             0.0170s ci_sources_pipeline

After

[TEST PROF INFO] EventProf results for sql.active_record

Total time: 00:08.765 of 00:21.700 (40.39%)
Total events: 6370

Top 5 slowest suites (by time):

Ci::RetryBuildService (./spec/services/ci/retry_build_service_spec.rb:5) – 00:08.765 (6370 / 161) of 00:21.700 (40.39%)



Finished in 26.97 seconds (files took 3.72 seconds to load)
161 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 97
 Total top-level: 84
 Total time: 3.3976s
 Total uniq factories: 18

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

      52          52        0.7021s            0.0135s             0.7021s    ci_job_artifact
      10          10        0.9125s            0.0913s             0.9125s           ci_build
       6           6        0.0339s            0.0056s             0.0339s      ci_build_need
       4           2        0.6968s            0.1742s             0.6241s               user
       3           3        0.0465s            0.0155s             0.0465s    ci_stage_entity
       2           2        0.2421s            0.1210s             0.2421s        ci_pipeline
       2           2        0.0401s            0.0200s             0.0401s  ci_empty_pipeline
       2           0        0.0511s            0.0255s             0.0000s          ci_runner
       2           0        0.1133s            0.0566s             0.0000s ci_trigger_request
       2           0        0.0984s            0.0492s             0.0000s         ci_trigger
       2           0        0.0735s            0.0367s             0.0000s              owner
       2           0        0.0270s            0.0135s             0.0000s  ci_resource_group
       2           2        0.0288s            0.0144s             0.0288s    ci_job_variable
       2           2        0.0813s            0.0406s             0.0813s          ci_bridge
       1           1        0.0171s            0.0171s             0.0171s            license
       1           1        0.6525s            0.6525s             0.6525s            project
       1           0        0.0438s            0.0438s             0.0000s          namespace
       1           1        0.0166s            0.0166s             0.0166s ci_sources_pipeline

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