Slow Rails Partials in Virtual Box With Shared Folders

I'm building a Rails app using Virtual Box. The code is in a shared folder on Windows and the Rails server runs in the VM. I'm noticing a wicked performance drop rendering partials. I'm rendering 250 rows into a table. The inlined version of my code looks like this:

<% activities.each do |activity| -%>
  <tr id="activity-<%= activity.id -%>-row">
    <td><%= activity.name -%></td>
  </tr>
<% end -%>

The above code loads almost instantaneous in development mode. When I turn the inner <tr> into a partial, everything breaks down.

<% activities.each do |activity| -%>
  <%= render "row", activity: activity -%>
<% end -%>

Inside _row.html.erb I have

<tr id="activity-<%= activity.id -%>-row">
  <td><%= activity.name -%></td>
</tr>

It now takes almost 60 seconds to load the page!

The console shows

  ...200+ previous render statements
  Rendered admin/org/activities/_row.html.erb (0.8ms)
  Rendered admin/org/activities/_row.html.erb (0.7ms)
  Rendered admin/org/activities/_row.html.erb (0.7ms)
  Rendered admin/org/activities/_row.html.erb (1.0ms)
  Rendered admin/org/activities/_row.html.erb (0.8ms)
  Rendered admin/org/activities/_row.html.erb (0.8ms)
  Rendered admin/org/activities/_row.html.erb (0.8ms)
  Rendered admin/org/activities/_activities.html.erb (57231.0ms)

I'm assuming this is a virtual box problem. The console shows that each partial loads in .7ms to 1.6ms which suggests it's spending little time in Rails. The last line of the console shows that it takes 57 seconds for the page to load, which is no where near the sum of the individual partial load times.

Is there any way to speed this up, or is VirtualBox + shared folders a partial killer?

Answers


I eventually abandoned shared folders in Virtual Box. I still use them for moving files between the host and guest, but I no longer let development code live in the shared folder.

For my current development setup, I have a separate dev folder inside the VM. This folder is not shared. I then use SublimeText plus the SFTP package, to edit files on the Windows side. I have a duplicate dev folder on my Windows box and the SFTP plugin keeps the VM dev folder synced with the Windows dev folder. I've run into a couple syncing problems here and there (where a file doesn't automatically get pushed to the VM correctly), but for the most part I have a good workflow going. I can now anticipate which types of edits in Windows might cause a sync problem.

The payoff is worth the syncing issues. I now run the rails server and files 100% in the VM. This has decreased my average page load time from about 4-7seconds, to about 200ms.

In addition, @basia's suggestion about rendering a collection into the partial was a helpful solution when trying to solve the problem with shared folders. It's even faster when not using shared folders.


Need Your Help

Twitter bootstrap modal not working

javascript jquery twitter-bootstrap modal-dialog

I am new to Twitter Bootstrap. I am working on a modal panel, but it is not being displayed. It fades the screen, but the modal itself does not appear. I have checked the error console, and there a...

Where can I find a list of Rails error messages keys?

ruby-on-rails localization validation

I'm trying to customize my error messages by modifying en.yml.