Async render in the views (kind of AR .load_async but for views, 5-15% performance improvement)

Hello, want to present a new gem:

GitHub - igorkasyanchuk/async_render: The true Async Render in Rails - render your views asynchronously, similar to AR load_async. But now for views.

Please review and challenge the solution. I think it can be improved even more, but even with the current implementation, you can get 5-15% speed improvements with just a few lines of code.

1 Like

How does this compare to eager/lazy loaded turbo frames?

no additional requests, no additional API endpoints, all happens inside the initial request and returned as a whole HTML

I can see a speedup from memoizing, and maybe from a database or other IO call, but I don’t imagine that rendering Views concurrently in Threads would be any faster, and would likely be slower, than doing them serially. That’s because View Rendering is CPU bound, and the Ruby GVL would mean that only 1 thread at a time would ever be running.

Yes, it will be faster, but maybe not in every situation. I know that on my pet project, I have the actual result, I can see the numbers. There is no need to use it to render the simple shared/google_analytics partial. I think I mentioned it in the gem, that gem is not for all cases.

Interestingly, you are saying it will not work, even without trying :slight_smile: . Maybe, with an example of rendering 100K

it won’t, but on real-world application I think it will.