On Tue, Feb 06, 2007 at 05:10:58PM +0900, Philippe L. wrote:
More and more files are being added to my client ruby application, and
it is getting quite slow to start, even on a fast machine. It takes
about 15 seconds in some cases.
The problem is with the call to “require” for the application
“workspace” object. This “require” points to files which in turn call
“require” for other files, and so on.
Is there a way to speed up the application load time maybe?
Are you loading files managed by RubyGems?
RubyGems’ #require implementation is known to be very slow. Things
against you include:
- required files from many different gems
- lots of installed gems
You can try to uninstall some gems (for instance unused, old versions),
hardcode the require paths:
prefix = “/usr/local”
%w[foo-0.1.1/lib bar-0.1/lib].each do |dir|
Another thing that can help (in general, not only when you’re using
is lazy loading using Kernel#autoload.