Skip set_repo_refs to speed up the tests
What does this MR do?
Any created repository in tests sets repo refs, but it's not necessary. What about setting the refs only for the tests that actually need it?
I ran TEST_STACK_PROF=1 rspec spec/models/project_spec.rb
and received the following results:
==================================
Mode: wall(1000)
Samples: 95153 (19.81% miss rate)
GC: 6858 (7.21%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
37707 (39.6%) 9894 (10.4%) ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#exec_no_cache
2780 (2.9%) 2780 (2.9%) #<Module:0x00007fedf79bed98>.storage_to_output
9656 (10.1%) 2435 (2.6%) ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements#execute
7418 (7.8%) 2430 (2.6%) TestEnv#set_repo_refs
3955 (4.2%) 1977 (2.1%) TestEnv#start_gitaly
This happens, because every project created with a test_env
repo runs TestEnv.copy_repo
which also runs set_repo_refs
, which roughly executes 0.25s
on my local machince.
Removal of set_repo_refs
reduces the execution time of spec/models/project_spec.rb
from:
Finished in 1 minute 50.67 seconds
to
Finished in 1 minute 29.24 seconds
and will also reduce the time for other specs which use create(:project, :repository)
Edited by Igor Drozdov