Skip to content

Speed up metrics dashboard annotation policy specs

Peter Leitzen requested to merge pl-spec-perf-metrics-dashboard-annotations into master

What does this MR do?

This MR improves the performance of metrics dashboard annotation policy specs by using let_it_be where applicable.

Related to &3752.

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

  • Total amount of factories created went down from 177 to 11 🚀
  • A tiny speed improvement from ~19s down to ~12s

Before

Finished in 18.59 seconds (files took 2.04 seconds to load)
32 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 177
 Total top-level: 97
 Total time: 9.0351s
 Total uniq factories: 7

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

      48          32        2.2580s            0.0470s             1.2036s               user
      32           0        5.8768s            0.1837s             0.0000s            project
      32           0        1.4873s            0.0465s             0.0000s          namespace
      32          32        0.1483s            0.0046s             0.1483s metrics_dashboard_annotation
      16          16        4.5745s            0.2859s             4.5745s            cluster
      16          16        3.0968s            0.1936s             3.0968s        environment
       1           1        0.0119s            0.0119s             0.0119s            license

Total sql.active_record events: 4233

After

32 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 11
 Total top-level: 6
 Total time: 0.8200s
 Total uniq factories: 7

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

       2           1        0.1116s            0.0558s             0.0743s               user
       2           0        0.5364s            0.2682s             0.0000s            project
       2           0        0.0714s            0.0357s             0.0000s          namespace
       2           2        0.0260s            0.0130s             0.0260s metrics_dashboard_annotation
       1           1        0.0061s            0.0061s             0.0061s            license
       1           1        0.4691s            0.4691s             0.4691s            cluster
       1           1        0.2445s            0.2445s             0.2445s        environment

Total sql.active_record events: 1345

Queries saved: 2888

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