Speed up CI job `rspec frontend_fixture` by skipping database load balancing
What does this MR do and why?
Skip:
-
ActiveRecord::Base.singleton_class.prepend(Gitlab::Database::LoadBalancing::ActiveRecordProxy)
and Gitlab::Database.main.disable_prepared_statements
For rspec frontend_fixture
related jobs, because they're critical to other frontend jobs and will need to run faster.
How faster was this?
For rspec frontend_fixture 1/2
https://gitlab.com/gitlab-org/gitlab/-/jobs/1635012421
==> 'bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee' succeeded in 26 seconds.
Whereas for the same job on master https://gitlab.com/gitlab-org/gitlab/-/jobs/1634810972
==> 'bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee' succeeded in 119 seconds.
And overall that's 6m34s vs 8m49s. A lot of frontend jobs can only run after this, so this is pretty critical, and it probably doesn't really need to care about database load balancing after all.
Background
Experimenting for #341757 (closed)
Testing with/without this line:
ActiveRecord::Base.singleton_class.prepend(Gitlab::Database::LoadBalancing::ActiveRecordProxy)
And see how long this command runs in CI:
bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee
Results:
- Removed the line. Took 38 seconds: https://gitlab.com/gitlab-org/gitlab/-/jobs/1626779036
- Kept the line. Took 97 seconds: https://gitlab.com/gitlab-org/gitlab/-/jobs/1626617743
- If we also enable prepared statements (remove
Gitlab::Database.main.disable_prepared_statements
), it took 31 seconds: https://gitlab.com/gitlab-org/gitlab/-/jobs/1626582054
Failed attempts to optimize this
- Tried to reduce closures: 26d3d5d5
- Still took 102 seconds: https://gitlab.com/gitlab-org/gitlab/-/jobs/1630135195
See #341757 (closed)
Related changes: !71459 (closed)
Edited by Lin Jen-Shin