Activerecord preload, causing aftereffect performance degradation

Fulfill a large activerecord request with a large number of peripheral objects.

Adding ".includes" (preloading) greatly speeds it up, crushing all N + 1's.

Then the page is quickly displayed and spits it out into the logs:

Completed 200 OK in 504ms (Views: 104.2ms | ActiveRecord: 86.0ms)

However, then it will be * 90 SECONDS * until the page is sent to the browser (or curl, we tested with both). A.

During this time, the ruby ​​process has a processor tied to 100%.

If we remove the ".includes" (preload), it returns to normal flabby performance without an hour and a half gulf of insignificance between the browser rendering and delivery pages.

WTF causes preload after effect !?

One colleague suggested the problem of garbage collection; How can I test this theory?

Rails 3.2.12

Ruby 1.9.3 (p286 and p327 checked)

+5
source share
1 answer

Found a problem; it was a Bullet gem ( https://github.com/flyerhzm/bullet ).

This gem skillfully finds and reports N + 1 queries and overly complicates, but in the case of very large result sets it significantly reduces application performance.

+1
source

All Articles