TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Speeding up Rails startup time

152 pointsby ddagradialmost 14 years ago

11 comments

jpetersonalmost 14 years ago
Couple things:<p>* 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.<p>* For all of you waiting for this to be pulled into Ruby master. Why not just patch your copy in the meantime?
评论 #2595276 未加载
nestlequ1kalmost 14 years ago
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.<p>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.<p>The last major external fix to ruby was with the REE people, and that <i>still</i> 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.
评论 #2595273 未加载
评论 #2596382 未加载
cduanalmost 14 years ago
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.<p>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?
评论 #2596076 未加载
评论 #2595760 未加载
评论 #2596934 未加载
sigilalmost 14 years ago
Given the roots in Perl, which has the %INC hash, it's surprising that Ruby started with an array for loaded modules. Can anyone shed some light on this design decision? Surely there was a reason at some point -- and maybe there still is.
ddagradialmost 14 years ago
Makes me wonder how many more "simple" optimizations can be made to the Rails stack. Very exciting!
keyistalmost 14 years ago
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 <a href="https://gist.github.com/975509" rel="nofollow">https://gist.github.com/975509</a> ).<p>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.
评论 #2595442 未加载
Sapientalmost 14 years ago
This patch seems to introduce a bug when loading files with extra periods in the name (I think).<p>My app which includes thinking-sphinx (which has a require '0.9.9'), breaks with it.
评论 #2596142 未加载
atamboalmost 14 years ago
Does this problem exist in jruby and rubinius as well?
评论 #2596144 未加载
jmtamealmost 14 years ago
on the topic of rails, has anyone noticed images loading slowly on localhost with 3.1?
评论 #2595523 未加载
saturnalmost 14 years ago
Wish I could vote for this to be in 1.9.3 as easily as I can vote for it on HN.
评论 #2594939 未加载
urielalmost 14 years ago
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.<p>I used rails in a few projects, and performance was so painful even on pretty good hardware that I said <i>never again</i>. Go on the other hand is pure pleasure.
评论 #2596244 未加载