Skip to content

Commit 661d8ec

Browse files
committed
Improve RSPEC parallel task split
Before specs:all rake task did split up all specs on all executors randomly. This ended up in threads with many small tests idling and wasting resources. The new method on the first run assigns tests based on the file size(more tests means more work) and after the first run buy the execution time which was measured into the tmp/parallel_runtime_rspec.log file. Ultimately ensuring a more even distribution of work between the rspec executors.
1 parent 7434a62 commit 661d8ec

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/tasks/spec.rake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@ namespace :spec do
4242
end
4343

4444
def run_specs_parallel(path, env_vars='')
45+
group_by_command = if File.exist?('tmp/parallel_runtime_rspec.log')
46+
'--group-by runtime'
47+
else
48+
'--group-by filesize'
49+
end
50+
4551
command = <<~CMD
4652
#{env_vars} bundle exec parallel_rspec \
4753
-n `ruby -e 'require "etc"; puts (Etc.nprocessors * (ENV["PARALLEL_TEST_PROCESSORS_MULTIPLE"] || 0.8).to_f).to_i'` \
54+
#{group_by_command} \
4855
--test-options '--order rand' \
4956
--single spec/integration/ \
5057
--single spec/acceptance/ \

0 commit comments

Comments
 (0)