Live data from Hacker News

Speeding up Rails startup time

rhnh.net

21–30 of 33 posts

Re: Speeding up Rails startup time

#21
post #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 Rail…

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.

FWIW, this is how Spork works, a tool people have been using a lot more recently in order to have fast(er) tests on Rails 3. Spork boots up an environment then waits for RSpec (or whatever) to hit it over DRb and then it forks off for that run.

Re: Speeding up Rails startup time

#22

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.

tenderlove is going to follow up on this. The issue is for metal-like responders, not for full-fledged apps. We've lost a couple of ms on the low-end due to the stack issue.

Re: Speeding up Rails startup time

#23
Sorry for the snide comment, but if you want to really speed up your Rails, switch to Go, it will compile from scratch and start up your project faster than the ruby interpreter starts up.

I used rails in a few projects, and performance was so painful even on pretty good hardware that I said never again. Go on the other hand is pure pleasure.

Re: Speeding up Rails startup time

#24
post #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 Rail…

I've always thought it would be nice if you could cause Ruby to dump its heap and symbol table to a file...

Another full circle back to Lisp. Dumping a Lisp image file is much like you describe. (Just sayin'.)

Re: Speeding up Rails startup time

#25

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.

As of now, there are none outstanding that I know of.

Re: Speeding up Rails startup time

#28
post #23

Sorry for the snide comment, but if you want to really speed up your Rails, switch to Go, it will compile from scratch and start up your project faster than the ruby interpreter starts up. I used rails in a few projects, and performance was so painful even on pretty good hardware that I said never again . Go on the other hand is pure pleasure.

This is a bit like saying, "If you want to get better gas mileage out of your car, walk." Switching to Go would be throwing the baby out with the bathwater. If you like Go, that's good, but people who are using Ruby and Rails presumably like those technologies. It's unlikely that somebody would choose Rails based solely on a mistaken assumption that it has the fastest possible runtime.

Re: Speeding up Rails startup time

#29

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…

As a followup, while this patch works great, using it forces you onto ruby-head which breaks a ton of shit.

I'm back to shit rails bootup speeds for now. But at least I now have hope that it's possible that a fix may be on the horizon.

joevandyk posted a great example project here: https://github.com/joevandyk/slow-rails

20second bootup of an empty project = hair on fire omgwtf issue. the start of phpenvy? (no, not really)

Re: Speeding up Rails startup time

#30
post #16

This patch seems to introduce a bug when loading files with extra periods in the name (I think). My app which includes thinking-sphinx (which has a require '0.9.9'), breaks with it.

This has been fixed and the post updated.

Yep, I saw, thanks!
Post reply on HN