I’m helping someone diagnose some slowness with their RoR applications. I’m not that deep into ruby development, but by running an strace on the ruby process, I noticed the following oddity:
For presumably every .rb file included, the ruby process checks about 110 different locations for the file to include, with all but 1 returning ENOENT. These paths include many non-existent permutations on local directories and gem installation directories. Ironically, the 8th location attempted finds the correct path, but ruby then goes on to try another 100 invalid locations before going back and opening the file it had found at the beginning of the search.
The whole search process takes almost 30ms per included .rb file, which cumulatively means that page takes so long to load that the site is unusable.
I’ve posted a sample of the strace output in case it is helpful here: http://pastebin.com/t9LD89dr
So, why is it doing this, and how do I make it stop?
This is a known problem with Ruby’s require… apparently they’re going to fix it with Ruby 1.9.3.
So, this slowness is hard to avoid when spinning up a Ruby app.