-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Performance Regression in 3.4.1 #1537
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
Comments
Subscribe. |
@dougal any chance you could work up a PR to fix this? |
After a short while with 3.4.1Using DTrace I was able to see that under 3.4.1, the view code was searching for templates from the disk, many times:
(The calls are for different variants of possible template names, It then opens the template:
And reads it:
3.4.0None of this happens under 3.4.0. Here are the same commands:
I have posted the full DTrace output for both versions as a Gist. Cause?3.4.0 subclassed I am now looking into subclassing |
@pixeltrix or @sgrif can you advise here? |
I'm currently out of the country, but I will be happy to take a look on Friday. |
@samphippen looks like the # rspec-rails-3.4.0
$ rspec spec/controllers/badgers_controller_spec.rb
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Finished in 2.1 seconds (files took 2.9 seconds to load)
1000 examples, 0 failures
# rspec-rails-3.4.1
$ rspec spec/controllers/badgers_controller_spec.rb
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Finished in 6.1 seconds (files took 2.86 seconds to load)
1000 examples, 0 failures
# rspec-rails-3.4.1+ ActionView::OptimizedFileSystemResolver
$ rspec spec/controllers/badgers_controller_spec.rb
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Finished in 4.16 seconds (files took 2.85 seconds to load)
1000 examples, 0 failures The implementation for |
@pixeltrix what if you |
@samphippen I don't think that |
@samphippen also just checked that block of code is executed the same number of times in 3.4.0 and 3.4.1 |
@samphippen it's because in 3.4.1 when we're creating the new resolvers in the view paths it's blowing away the cache, whereas it wasn't in 3.4.0 because it wrapped the existing resolvers by decorating the view paths. I think I have a way to fix it without reaching inside the internals of |
Closes rspec#1537. The change in 80637fc introduced a performance regression because the template lookup cache was being lost every time an example was run. This commit fixes the problem by caching the EmptyTemplateResolver instances between example runs in a hash indexed by the path string.
Closes rspec#1537. The change in 80637fc introduced a performance regression because the template lookup cache was being lost every time an example was run. This commit fixes the problem by caching the EmptyTemplateResolver instances between example runs in a hash indexed by the path string.
Just got a chance to look at this. It looks like you guys have it covered. I just wanted to mention the irony of the fact that "Optimized"FileSystemResolver is the source of the regression. Very optimized... Ok I'll go away now. |
Closes rspec#1537. The change in 80637fc introduced a performance regression because the template lookup cache was being lost every time an example was run. This commit fixes the problem by caching the EmptyTemplateResolver instances between example runs in a hash indexed by the path string.
While running specs on a large application I maintain, I noticed a significant slowdown in running controller specs where the action would ordinarily render a template, when using 3.4.1 as compared to 3.4.0.
I have provided an example application which demonstrates this.
Benchmarking
The results I am seeing (using the timing in RSpec's own output) are:
3.4.0
Run 1: 2.51s
Run 2: 2.55s
Run 3: 2.54s
Average: 2.53s
3.4.1
Run 1: 6.99s
Run 2: 7.04s
Run 3: 7.06s
Average: 7.03s
Conjecture
I suspect this is related to the changes in PR #1535, specifically the commit 42b44a6. Having a quick look at the commit, there are at least two extra
map
operations in there compared to previously. I am not familiar with the code, and have not yet had the time to run a profiler with the specs in my example application to see if the extra iteration or resulting allocations are indeed the cause. I hope to do so tomorrow.The text was updated successfully, but these errors were encountered: