Speed up group finder specs by using let_it_be in shared context
What does this MR do?
This MR improves the performance of Core (spec/finders/group_projects_finder_spec.rb
) end EE (ee/spec/finders/group_projects_finder_spec.rb
) group finder specs by using let_it_be
in the shared context.
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 757 to 98🚀 -
Total events
went down from 16554 to 3192 - Queries saved: 6799
Before
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:23.137 of 00:44.066 (52.51%)
Total events: 16554
Top 5 slowest suites (by time):
GroupProjectsFinder (./spec/finders/group_projects_finder_spec.rb:5) – 00:18.801 (13669 / 26) of 00:35.932 (52.32%)
GroupProjectsFinder (./ee/spec/finders/group_projects_finder_spec.rb:5) – 00:04.335 (2885 / 5) of 00:08.133 (53.31%)
Finished in 51.15 seconds (files took 2.16 seconds to load)
31 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 757
Total top-level: 327
Total time: 41.1812s
Total uniq factories: 13
total top-level total time time per call top-level time name
232 230 37.9746s 0.1637s 37.6019s project
232 0 9.4744s 0.0408s 0.0000s namespace
156 28 5.8063s 0.0372s 0.9506s user
62 0 0.2729s 0.0044s 0.0000s namespace_settings
61 61 1.8176s 0.0298s 1.8176s group
3 3 0.0949s 0.0316s 0.0949s admin
2 2 0.0120s 0.0060s 0.0120s license
2 2 0.6435s 0.3218s 0.6435s ee_ci_job_artifact
2 0 0.6017s 0.3009s 0.0000s ci_build
2 0 0.4306s 0.2153s 0.0000s ci_pipeline
1 1 0.0606s 0.0606s 0.0606s group_with_plan
1 0 0.0131s 0.0131s 0.0000s gold_plan
1 0 0.0208s 0.0208s 0.0000s gitlab_subscription
After
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:03.766 of 00:07.817 (48.17%)
Total events: 3192
Top 5 slowest suites (by time):
GroupProjectsFinder (./spec/finders/group_projects_finder_spec.rb:5) – 00:02.451 (2102 / 26) of 00:04.999 (49.05%)
GroupProjectsFinder (./ee/spec/finders/group_projects_finder_spec.rb:5) – 00:01.314 (1090 / 5) of 00:02.818 (46.63%)
Finished in 15.26 seconds (files took 2.24 seconds to load)
31 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 98
Total top-level: 44
Total time: 5.2459s
Total uniq factories: 13
total top-level total time time per call top-level time name
29 27 4.3582s 0.1503s 3.9315s project
29 0 0.9217s 0.0318s 0.0000s namespace
17 5 0.6188s 0.0364s 0.1815s user
5 0 0.0239s 0.0048s 0.0000s namespace_settings
4 4 0.1247s 0.0312s 0.1247s group
3 3 0.1017s 0.0339s 0.1017s admin
2 2 0.0124s 0.0062s 0.0124s license
2 2 0.7410s 0.3705s 0.7410s ee_ci_job_artifact
2 0 0.6711s 0.3355s 0.0000s ci_build
2 0 0.5038s 0.2519s 0.0000s ci_pipeline
1 1 0.1531s 0.1531s 0.1531s group_with_plan
1 0 0.0171s 0.0171s 0.0000s gold_plan
1 0 0.0276s 0.0276s 0.0000s gitlab_subscription
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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