Live data from Hacker News

Rails 3 Performance - Not Good Enough

blog.tstmedia.com

71–80 of 142 posts

Re: Rails 3 Performance - Not Good Enough

#71
post #64
post #18

Earlier quoted context omitted.

Yeah, 400 ms spent on average just in Ruby on a modern server is really absurd, though. Think about that - half a second, before anything to do with the database. I try to shoot for sub-100ms avg. total, this would probably drive me insane. I don't think I've ever managed to write a PHP page that took more than 100ms on average for the PHP alone on a decent server, and it's not from a lack of abuse.

I have no idea where you get 400ms on average. Here's the log for a blog post page of my site. It's a heavy and big page, it's on ruby 1.8.7 and rails 3, and I haven't done anything to make it faster. I could cache most of it rather easily. Completed 200 OK in 205ms (Views: 168.9ms | ActiveRecord: 23.2ms | Sphinx: 9.6ms) edit: a couple of notes. This is running on a cheap vps and would be faster on a real server. It…

Performance depends on the application. You are spending 168ms rendering. If the page had a few more partials or some more data, you could be seeing 400ms for that page easily.

Rails view/partial rendering is pretty slow in general.

Re: Rails 3 Performance - Not Good Enough

#72
post #53

I've been a Rails dev for 5 years. I'm frequently considering leaving for another framework because of one thing: bootstrap time. Starting a test or server on my dev machine takes 20-30 seconds. Particularly with tests, this is a huge problem for doing proper TDD, particularly when you are trying to use tests to track down a bug. In that 20-30 seconds, I often console myself that we no longer need to print punch card…

I haven't been using Rails for nearly as long as you have. As a result, I thought the bootstrap time was something Rails developers just "put up with". I would have thought that someone else would have noticed this problem and done something about it...surprisingly I don't think many have. Django, by comparison, bootstraps the environment almost instantly. I have also been looking for an answer for how to deal with t…

Yeah, I tried Django 2 years ago and sort of wish I had stuck with it primarily for this reason. (Additionally I much prefer the Python "no magic" philosophy, although I've gotten used to tracing through Ruby craziness.)

The Rails community (at least at the time) was so much larger and more open that it seemed like a better bet. Rails 3 was coming up and I knew Yehuda was doing brilliant things with the Rails 3.0 architecture. Plus, Moore's law right? - not helping!

I'd love for some hard core Rails guys to get in here and offer some real solutions! As much as I have issues with some things about Rails, it is largely a great tool for me, and I know it so well I'd like to be able to continue using it without tearing my hair out every time I need to run a simple test.

Re: Rails 3 Performance - Not Good Enough

#73
post #34

Earlier quoted context omitted.

That commit made certain pages of my app about 10 times slower. This was such an appalling performance degradation that I had to do some digging: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/... https://gist.github.com/919428 https://github.com/rails/rails/commit/a3639be4ed5e89b59c4ad0... The commit mostly fixes that particular issue (and is included in 3.0.7), but as the article point out Rails 3 AR p…

Judging by the comments on that commit and the comments in this HN post, I would say that many of the performance regressions are only happening under ruby 1.8.x. By this time, I wonder what the rails developers should spend their time with: making the framework better for people running the current version of the language or fixing performance problems due to shortcomings of the old version? If you can't upgrade to…

I'm finding it's not that people can't upgrade to 1.9.2, it's that many don't want to.

I have a pretty decent-sized application running on REE and Rails 2.3.x. I've made my code fully 1.9.2 compatible. My specs take on average 3.5 times longer to run in 1.9.2. Profiling that shows that close to 60% of the time is spent in Kernel#require. Now, it's pretty common for people to say only profile in the production environment, but I need to be able to run my specs. And it's not acceptable to shell that out to a CI server or to run REE in dev. mode and deploy with 1.9.2. Running in spork is a gross approximation, too; I've seen way too many issues there.

My suspicion is that if you have a small enough project, the speed difference is negligible. If you have a large project, it becomes much more pronounced. So, it'd really be nice for me to continue to upgrade and improve my Rails-based app without having to drag along an environment that's going to hobble me.

FWIW, I do know people that have started on 1.9.2 and rolled back to REE because speed was such a problem.

Re: Rails 3 Performance - Not Good Enough

#74
post #53

I've been a Rails dev for 5 years. I'm frequently considering leaving for another framework because of one thing: bootstrap time. Starting a test or server on my dev machine takes 20-30 seconds. Particularly with tests, this is a huge problem for doing proper TDD, particularly when you are trying to use tests to track down a bug. In that 20-30 seconds, I often console myself that we no longer need to print punch card…

One thing I've been investigating is using RabbitMQ to separate the logic out of the monolithic rails application. Beetle looks promising. http://xing.github.com/beetle/ You can do both RPC and async messaging. (Might want to wait a few days before using it, there's issues with some libraries that it depends on that will be fixed soon).

I don't understand how that helps. This is a problem for pretty simple Rails applications.

Besides, why should I have to set up and learn RabbitMQ to have a decently performing web framework? This is 2011 and this shit is slower than my old Java framework running on an ancient processor in 1995.

Re: Rails 3 Performance - Not Good Enough

#75

Earlier quoted context omitted.

I hear what you are saying about exceptions, but you also have to live in reality. Look at danielparks benchmarks in this thread; rails3 under 1.9.2 is faster than rails2 under 1.8.7. Its easy enough to spout platitudes like "don't use exceptions for flow control", except remember two basic facts about the commit that I linked: 1. It was using exceptions for flow control as an optimization 2. That optimization was in…

Obviously, I didn't form my opinion on that attitude based on this particular issue. But maybe you're right and the Rails leopard has actually changed its spots. Apart from that, it's unclear whether the slowdown in NGIN is caused by this one line of code alone.

To be clear, I don't think that the NGIN slowdown is caused by this exception stuff, because that has been taken out and was really a different performance problem altogether. I only raised it because it was similar -- a problem only on 1.8.7 that was fixed as soon as someone mentioned it.

I think it is very interesting that the specific test produced in the original post is actually faster under Rails 3 and Ruby 1.9.2 than it is under Rails 2 and 1.8.7.

My only grief with you, fauigerzigerk, is that you claim the Rails team doesn't "give a shit about performance", when the performance problems seem to be related to people using an older version of Ruby. I think you are making an extraordinary claim -- that the rails team doesn't "give a shit", in in fact, they clear do give a shit.

Re: Rails 3 Performance - Not Good Enough

#76
post #64

Earlier quoted context omitted.

I have no idea where you get 400ms on average. Here's the log for a blog post page of my site. It's a heavy and big page, it's on ruby 1.8.7 and rails 3, and I haven't done anything to make it faster. I could cache most of it rather easily. Completed 200 OK in 205ms (Views: 168.9ms | ActiveRecord: 23.2ms | Sphinx: 9.6ms) edit: a couple of notes. This is running on a cheap vps and would be faster on a real server. It…

Performance depends on the application. You are spending 168ms rendering. If the page had a few more partials or some more data, you could be seeing 400ms for that page easily. Rails view/partial rendering is pretty slow in general.

i know, but as I said, that page is pretty heavy and it's not close to 400ms. It's on a cheap vps and using 1.8.7, And I could easily cache most of it.

I think the some people could have read the comment I replied to and believe that 400ms is somehow normal. It's not.

Re: Rails 3 Performance - Not Good Enough

#77
post #49

I think the real problem with Rails and similar frameworks is the culture of not giving a shit about performance. I would never ever release a new version of anything that is significantly slower than the previous one. It's simply a bug in my view. But there are people who have convinced themselves that as long as it scales out, it doesn't matter how many servers you have to run. And if the reason is that something t…

culture of not giving a shit about performance Yes. On top of that the ruby ecosystem also seems to attract a certain class of programmers who simply don't know how their magic ruby code translates to CPU, I/O and memory operations. My pet example is a certain popular rails auth framework that hits the database for every single request, to look up tokens that could simply be baked into the cookie. But there are plent…

Out of curiosity, to which "popular rails auth framework" are you referring? Devise? Authlogic?

Re: Rails 3 Performance - Not Good Enough

#78
post #53

I've been a Rails dev for 5 years. I'm frequently considering leaving for another framework because of one thing: bootstrap time. Starting a test or server on my dev machine takes 20-30 seconds. Particularly with tests, this is a huge problem for doing proper TDD, particularly when you are trying to use tests to track down a bug. In that 20-30 seconds, I often console myself that we no longer need to print punch card…

I dunno, I've been at this for 6 years with Rails, am running a 4 year old mbp that dogs it with Java stuff but hangs in ust fine with Ruby. Maybe my apps aren't nearly as huge as the ones you're loading, but I've done some large ones.

But I share your frustrations re: "metawhare" :) Solution is just to hang around with responsible devs.

Re: Rails 3 Performance - Not Good Enough

#79
post #69
post #57

Earlier quoted context omitted.

How often do you need to endure that 20-30 second startup time? Is it every time you change anything?

Pretty much ANYTHING you do. Start a console, start a server, run a test, migrate your database, run a rake task. It's a huge productivity killer for me. And as other comments have stated, it's surprising this issue is not discussed more.

Not solutions, but workarounds:

Keep console open and use reload! when you change your models, for starting a server I don't have much other than keep it running the background, running a test -- use spork, migrate your db and run rake tasks -- try to take advantage of the fact that you can specify multiple rake tasks at a time; "rake db:migrate db:test:prepare"

Re: Rails 3 Performance - Not Good Enough

#80
post #58

Interesting, though I no longer use ActiveRecord in my largest app because of how slow it is (even in Rails 2). Try checking the overhead of instantiating (no save or db lookup) a simple model instance with 2 fields for example. If you manage to avoid that, you've beaten the slowest parts. The view engine is also slow but I tend to do rendering in the browser these days so that barely matters too me. If you are caref…

What would you suggest to use instead of ActiveRecord in a Rails 3 app?
Post reply on HN