3 ms·
> Inefficient Rendering (IR). This one was a surprise to me He's talking about the common Rails pattern of rendering a small Haml/ERB partial over & over in a
by pjungwir 8y ago
> Inefficient Rendering (IR). This one was a surprise to me
He's talking about the common Rails pattern of rendering a small Haml/ERB partial over & over in a loop. I've noticed big perf hits from this before, but never completely understood why. Rendering the exact same result directly in the loop body, without calling a second partial, gives a big speedup.
There is an extensive discussion here:
https://softwareengineering.stackexchange.com/questions/157108/rails-does-using-partials-slow-views-rendering https://softwareengineering.stackexchange.com/questions/1571...
I would love to have some better understanding around this, although it sounds like no one has a clear idea of the cause.
In development, I've noticed that Rails re-reads the partial file off disk every iteration of the loop. I don't know if that happens in production too, but if so it would explain a lot.