Skip to content
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

Nested fields rendering is very slow in Rails 4.2.1 #1237

Closed
tanraya opened this issue Apr 5, 2015 · 16 comments
Closed

Nested fields rendering is very slow in Rails 4.2.1 #1237

tanraya opened this issue Apr 5, 2015 · 16 comments

Comments

@tanraya
Copy link

tanraya commented Apr 5, 2015

Just switched to Rails 4.2.1 and found an performance issue with simple_filelds_for rendering.

In Rails 4.1.6 it works fast enough:

Rendered shared/_phone_fields.html.erb (59.0ms)

However, in Rails 4.2.1 it works quite slowly:

Rendered shared/_phone_fields.html.erb (226.1ms)

In both rails versions the code is the same (simplified):

  <%= f.simple_fields_for :phones, f.object.phones do |b| %>
    <%= f.input :city_code %>
    <%= f.input :phone %>
  <% end %>

If I change the code to default rails form helpers, it works without performance drops.

Here's the ruby-prof stats for Rails 4.2.1 http://pastebin.com/NSXwCBEU and for 4.1.6 http://pastebin.com/4waUaveA

Any suggestions or ideas?

@carlosantoniodasilva
Copy link
Member

Interesting, did anything else change besides the Rails version? For example, I18n, or any other gem. Also, which Ruby version are you using?

We may need to try to isolate that into a new app somehow to figure out what could be causing this. Thanks for your report.

@tanraya
Copy link
Author

tanraya commented Apr 6, 2015

I will create isolated rails app today and try to find an issue.

@tanraya
Copy link
Author

tanraya commented Apr 6, 2015

Hmm. It seems it is an issue with one of gems in the app. I'll continue researching, then put results here.

@tanraya
Copy link
Author

tanraya commented Apr 6, 2015

Whew. I found the reason. It was binding_of_caller gem (the better_errors requirement).

This happens in Rails 4.2.1 and Ruby 2.1.1 on Linux Ubuntu 14.10.

Beware of using it until its developers didn't fix this bug.
Hope it will help someone to save time.

@carlosantoniodasilva
Copy link
Member

Awesome, thanks for reporting back ❤️, glad it's not a Simple Form issue :).

@alextakitani
Copy link

Had the same problem.

Rails 4.2.1, Ruby 2.16 and Ruby 2.2.2

disabling binding_of_caller didn't solved for me, disabling webconsole did.

@carlosantoniodasilva
Copy link
Member

web-console relies on binding_of_caller, perhaps it was still being activated?

@alextakitani
Copy link

After more tests:

On Ruby 2.2.2, disabling web-console, but maintaining better_errors and binding_of_caller solves the problem.

On Ruby 2.1.6 only by diabling them all solves it.

@carlosantoniodasilva, any tips on how can I investigate it further?

@carlosantoniodasilva
Copy link
Member

Interesting.. but this happens on development, or production? (and if it is production, why having those gems in there?)

I don't have any idea really, but maybe you could start by creating a sample app that shows and isolates the problem as much as possible, so that someone can try to help more easily.

@alextakitani
Copy link

Develoment ( i have those gems enabled only on dev ).

@mib32
Copy link

mib32 commented May 15, 2015

@tanraya how do you think, that was related to RubyVM::DebugInspector?

@diegorv
Copy link

diegorv commented May 29, 2015

Same here and I don't use any of this gems

  Rendered client/contracts/_payment_fields.html.erb (39.0ms)
  Rendered client/contracts/_payment_fields.html.erb (39.1ms)
  Rendered client/contracts/_payment_fields.html.erb (40.8ms)
  Rendered client/contracts/_payment_fields.html.erb (42.2ms)
  Rendered client/contracts/_payment_fields.html.erb (39.3ms)
  Rendered client/contracts/_payment_fields.html.erb (39.9ms)
  Rendered client/contracts/_payment_fields.html.erb (59.0ms)
  Rendered client/contracts/_payment_fields.html.erb (62.7ms)
  Rendered client/contracts/_payment_fields.html.erb (46.9ms)
  Rendered client/contracts/_payment_fields.html.erb (52.2ms)
  Rendered client/contracts/_payment_fields.html.erb (48.4ms)
  Rendered client/contracts/_payment_fields.html.erb (68.0ms)
  Rendered client/contracts/_payment_fields.html.erb (51.1ms)
  Rendered client/contracts/_payment_fields.html.erb (60.1ms)
  Rendered shared/theme/_form_div.html.erb (0.7ms)
  Rendered client/contracts/_payment_box.html.erb (739.0ms)

@carlosantoniodasilva any idea?

@diegorv
Copy link

diegorv commented May 29, 2015

Maybe related with #1227?

@darryn02
Copy link

Using Ruby 2.2.2, I also had the issue and resolved by removing web-console from Gemfile. Rendering times went from 700-1800ms to 40-70 ms. Whew!

I had found #1227 first and the suggestions there didn't help me.

@gregblass
Copy link

Seriously thank you for posting this. I was battling with a huge performance hit because of this bug. Removing better errors and binding of caller shaved a whole 3 seconds and got my page load down to 250ms.

awong-dev added a commit to department-of-veterans-affairs/SCIInterim that referenced this issue Sep 4, 2015
@awong-dev
Copy link

See #1227 (comment). I think the root cause is actually in simple_forms, not in binding_of_caller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants