Skip to content

Speed up specs for quick action interpret service

Peter Leitzen requested to merge pl-spec-interpret-service-perf into master

What does this MR do?

This MR improves the performance of quick actions' interpret service specs by using let_it_be and before_all where applicable.

Related to &3752.

Contributes to https://gitlab.com/gitlab-org/plan/-/issues/145 and also to #220040 (closed) (👮).

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

  • Total amount of factories created went down from 1538 to 317 🚀
  • Total events went down from 47710 to 12073
  • Queries saved: 35637

Before

[TEST PROF INFO] EventProf results for sql.active_record

Total time: 01:10.156 of 02:23.302 (48.96%)
Total events: 47710

Top 5 slowest suites (by time):

QuickActions::InterpretService (./spec/services/quick_actions/interpret_service_spec.rb:5) – 01:10.156 (47710 / 304) of 02:23.302 (48.96%)



Finished in 2 minutes 30.6 seconds (files took 5.59 seconds to load)
304 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 1538
 Total top-level: 1212
 Total time: 104.6680s
 Total uniq factories: 16

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

     347         339       15.0506s            0.0434s            14.7399s               user
     324         324       64.3489s            0.1986s            64.3489s            project
     318           0       16.0155s            0.0504s             0.0000s          namespace
     217         217       10.5660s            0.0487s            10.5660s              issue
     115         115        0.9947s            0.0086s             0.9947s              label
      90          90       10.8236s            0.1203s            10.8236s      merge_request
      45          45        0.5215s            0.0116s             0.5215s               list
      18          18        0.5187s            0.0288s             0.5187s          milestone
      18          18        0.5077s            0.0282s             0.5077s              board
      17          17        0.6227s            0.0366s             0.6227s              group
      13          13        0.0610s            0.0047s             0.0610s             commit
      11          11        0.8033s            0.0730s             0.8033s      labeled_issue
       2           2        0.0522s            0.0261s             0.0522s         draft_note
       1           1        0.0110s            0.0110s             0.0110s            license
       1           1        0.0903s            0.0903s             0.0903s        ci_pipeline
       1           1        0.0065s            0.0065s             0.0065s         issue_link

After

[TEST PROF INFO] EventProf results for sql.active_record

Total time: 00:16.865 of 00:41.964 (40.19%)
Total events: 12073

Top 5 slowest suites (by time):

QuickActions::InterpretService (./spec/services/quick_actions/interpret_service_spec.rb:5) – 00:16.865 (12073 / 304) of 00:41.964 (40.19%)



Finished in 49.32 seconds (files took 4.82 seconds to load)
304 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 317
 Total top-level: 288
 Total time: 24.2674s
 Total uniq factories: 16

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

      90          90       11.2419s            0.1249s            11.2419s      merge_request
      47          47        2.3599s            0.0502s             2.3599s              issue
      39          36        1.8965s            0.0486s             1.7921s               user
      30          30        0.3599s            0.0120s             0.3599s              label
      27          27        6.3906s            0.2367s             6.3906s            project
      26           0        1.4778s            0.0568s             0.0000s          namespace
      15          15        0.5861s            0.0391s             0.5861s          milestone
      13          13        0.1094s            0.0084s             0.1094s             commit
      11          11        0.6013s            0.0547s             0.6013s      labeled_issue
       7           7        0.3142s            0.0449s             0.3142s              group
       4           4        0.1292s            0.0323s             0.1292s              board
       3           3        0.1315s            0.0438s             0.1315s               list
       2           2        0.0432s            0.0216s             0.0432s         draft_note
       1           1        0.0175s            0.0175s             0.0175s            license
       1           1        0.1780s            0.1780s             0.1780s        ci_pipeline
       1           1        0.0126s            0.0126s             0.0126s         issue_link

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