Live data from Hacker News

Speeding up Rails startup time

rhnh.net

11–20 of 33 posts

Re: Speeding up Rails startup time

#11
Wow, amazing find. I've been struggling with this issue for many months, and I just figured it was rails 3.0 fault for being so big and bloated. Now we find out it's ruby implementation. I really hope this patch makes it in.

I've patched my local copy. Feels like I have doubled my computer speed! Seriously though, I can't believe the fix was so easy, and the ruby core hasn't done something about this yet.

The last major external fix to ruby was with the REE people, and that still hasn't made it back into MRI. So I'm a bit worried this patch will get rejected and the problem won't be fixed.

Re: Speeding up Rails startup time

#12

Wow, amazing find. I've been struggling with this issue for many months, and I just figured it was rails 3.0 fault for being so big and bloated. Now we find out it's ruby implementation. I really hope this patch makes it in. I've patched my local copy. Feels like I have doubled my computer speed! Seriously though, I can't believe the fix was so easy, and the ruby core hasn't done something about this yet. The last ma…

Rails does have problems with 3.0 being slow.

See http://www.youtube.com/watch?v=kWOAHIpmLAI&t=34m9s for a recent talk on it by @tenderlove.

Re: Speeding up Rails startup time

#13

Couple things: * Wow, an O(n^2) require algo. I guess this really drives home that we shouldn't make basic assumptions about the quality of the libs we use without actually looking at them. Great catch. * For all of you waiting for this to be pulled into Ruby master. Why not just patch your copy in the meantime?

The patch isn't done yet, there's still significant bugs to fix.

Re: Speeding up Rails startup time

#15
If you're not using Bundler and have a simple dependency chain, you can get further improvement from symlinking your gems into a single directory (see https://gist.github.com/975509 ).

This patch certainly improved my load time tremendously, but the core of the problem still lies with the way rubygems and bundler dump all directories of gems in the load path. The promise of $LOAD_PATH is that all the directories in it will be tried -- the most bang-for-buck optimization is thus minimizing its size.

Re: Speeding up Rails startup time

#17
I've always thought it would be nice if you could cause Ruby to dump its heap and symbol table to a file, which could then be loaded by other instances of Ruby. So, for example, you could run Ruby, load all of the Rails files, and then save everything, so the next time you want to run Rails, you just have to load one file instead of hitting the file system 2000 times.

You could probably also do this by running a Rails instance as a service, and then every time you want to run Rails, you tell the service to fork, and use the forked thread. I think this is how Passenger works actually?

Re: Speeding up Rails startup time

#18
post #15

If you're not using Bundler and have a simple dependency chain, you can get further improvement from symlinking your gems into a single directory (see https://gist.github.com/975509 ). This patch certainly improved my load time tremendously, but the core of the problem still lies with the way rubygems and bundler dump all directories of gems in the load path. The promise of $LOAD_PATH is that all the directories in i…

rpg works by installing everything on a common directory: https://github.com/rtomayko/rpg

If rubygems did this, everything would be much better.

There is one problem though, and it is that some libs are bad citizens and install stuff outside of lib|bin and depend on it (haml's VERSION file is an example of this), and that sucks.

rpg has a 'shitlist' with fixes for specific cases: https://github.com/rtomayko/rpg/blob/master/rpg-shit-list.sh...

Re: Speeding up Rails startup time

#19
post #14

on the topic of rails, has anyone noticed images loading slowly on localhost with 3.1?

I haven't tested this myself, but I can guess that they will load slower in development. In development asset requests go through the asset pipeline now instead of being directly served up through the HTTP server.

Re: Speeding up Rails startup time

#20
post #14

on the topic of rails, has anyone noticed images loading slowly on localhost with 3.1?

I haven't tested this myself, but I can guess that they will load slower in development. In development asset requests go through the asset pipeline now instead of being directly served up through the HTTP server.

is there a reason to dump your images into the assets vs public folder then?
Post reply on HN