-
-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
load times discrepancy between loading all verses single test or directory. #2611
Comments
@ChrisCPO I'm sorry to hear that, have you tried passing in all of the files manually? Theres some logic surrounding digging through all of the folders which might be improvable, and building a list of files outside of RSpec and passing them in might end up being faster? It'd be a good point to start looking into why this seems to take longer in the default command rather than per directory. If You might also wish to check your rails settings, if your "fast boot" is caused by turning off preload and using eager loading then thats actually going to be slower overall for you, as everything will be loaded as your specs are loaded. Its possible you have some really slow loading specs, which is hidden until you load all the files. |
Thanks for the Response @JonRowe
As of now it would appear the more files you load with
Wouldn't an issue like this show up when each spec directory is run separately? Which the sum of the load times are about 35 seconds. |
here is a weird part, our worst directory takes ~15 seconds to load when just that directory is loaded. Here are some load times from the same file:
The difference on the first file is 10x, these times are fairly consistent within a 5% variance. As I understand |
Well, you should be able to bench mark this! This is a... crude... attempt:
I warn you the fork is used to make the require of rails etc happen each time... |
My results from a real world project:
Showing what I'd typically expect, a reasonable load time caused by rails in each directory invoking it. |
Please feel free to reopen if there is something actionable in |
@ChrisCPO did you by any chance find the root cause for this? If so, did you manage to tackle it somehow? Thanks! |
I'm experiencing the same issue with a Rails 5.1 and rspec-core 3.8.0. We have 2676 spec files. @JonRowe I have a question about your script. Why do you also load the whole Using the script you provided, I measured the load times of each of the root spec paths in my app (I didn't benchmark the expand path because it was insignificant). Here are the results:
It strikes me that configuring the whole |
It is not expected to add up, but the subfolders added up should be more than the spec folder on its own. Some further benchmarking of your loading files might help here. |
@JonRowe I've modified your script to measure individual file load timings. It seems that, in the case where each folder is loaded separately, individual file load timings add up to 30s. In the last case, where all files are loaded via By comparing the timings of the same files in both cases, indeed in the spec/helpers/application_helper_spec.rb,0.764 # loaded via 'spec/helpers'
spec/helpers/application_helper_spec.rb,6.100631 # loaded via 'spec'
spec/views/skus/show/_details.html.erb_spec.rb,0.1617539999999999 # loaded via 'spec/views'
spec/views/skus/show/_details.html.erb_spec.rb,4.82285899999999 # loaded via 'spec' |
Can you please debug it further @agis? |
Can you run the script I produced? Your output before doesn't contain the This is important because it show'd that |
@JonRowe perhaps that wasn't clear from my previous comments, but Anyway, I did some more digging by profiling two Apparently, in the case of the "load In any case, the issue here is caused by the fact that
So from 118s., loading every file in I don't know if something can be done from RSpec's point of view. I could upload here the HTML profile generated from ruby-prof, of the slow References:
|
It does if its exponentially linked to the number of files / classes / modules.
Each If theres something we can do here please comment, otherwise I'm closing for now. |
TIme Discrepancy
We are noticing a very large time discrepancy between loading the entire suite verses, a directory, or a single test.
Versions
Ruby version: ruby 2.6.1p33
Rails version: Rails 5.1.6.2
RSpec version: RSpec 3.7
Observed behavior
We are noticing a very large time discrepancy between loading the entire suite verses, a directory, or a single test.
When
bundle exec rspec spec/models/user_spec.rb
=>
Finished... (files took 4 seconds to load)
When
bundle exec rspec spec/{directory}
Files take 10 to 20 seconds to load. Running the entire suite this way would take in total about 45 seconds to load.
When
bundle exec rspec spec
=>
Finished... (files took 4 minutes 24.9 seconds to load)
Greater then 4 minutes!
Our environment takes about 4 seconds to load.
Expected behavior
By adding the load times when loading each directory, I would assume that the entire suite would take about 40 - 50 seconds to load all of the files.
We are seeing this across multiple machines.
There are a lot of interwebs about load times, many are old as they point to spring. Though I was unable to find a reference about an issue like this.
Digging into this, the issue appears to be in
rspec-core/lib/rspec/core/configuration.rb
Line 1547 in 0b4c98d
files_to_run.uniq.each do ...
block takes our 4 minutes and change to load all 2k ish spec files.I don't think this is a monolithic app issue because totaling the load time when running each directory versus the full suite does not add up to over 4 minutes.
Considering that
load
is a kernel method... ?The text was updated successfully, but these errors were encountered: