-
Notifications
You must be signed in to change notification settings - Fork 96
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
Slow when using layout: false #32
Comments
Faced the same problem. This is what I've found. The performance bottleneck is at gem uses If you profile calls to class Dir
def self.new_get *args
puts "====================="
puts args.inspect
# puts caller(1)
r = nil
ms = Benchmark.ms {
r = old_get *args
}
puts ms
r
end
class << self
alias_method :old_get, :[]
alias_method :[], :new_get
end
end this is what i get
That's ~30 milliseconds to each To compare with normal call:
As you can see the normal call takes 1millisecond. The difference is for some reason
PS. this is tested on rails 5.0.0 Stack trace for the future
|
Continued... The question is why does it do that. Rails searches for templates with specific format first and if nothing is found then all formats are checked. In my case I render html request in ajax requests. Found a hack way to make it work before_action do
lookup_context.formats.unshift :html
end pretty much tell that we are interested in html templates when doing lookup. |
@antulik Thanks, you got the right point. As you mentioned, it seems that lookup_context.formats are occurring a bottleneck. And I fortunately solved like this in the controller: |
I hope this will be solved in 2018. I just ran into the same issue now, just to find this two year old issue. 😢 @antulik I know it's been a long time but did you remember how you found that bottleneck? I'm trying Update Adding action caching even slows down things a lot before the actual rendering. It seems that the line
causes the massive slow down. If I UPDATE 2 |
Trying to use this gem for caching a homepage that doesn't do much querying. However if I add
layout: false
then the speed drops dramatically.Speeds:
layout: false
: 200msSo using action caching without caching the layout is significantly slower than doing no caching. Any ideas what could be causing this?
The text was updated successfully, but these errors were encountered: