On Thu, 2006-08-17 at 18:41 -0400, heri rakotomalala wrote:
or 43things and they reckon it could be faster. they don’t know about
database or RAM problems or processing power. and you agree with me
that users have the ultimate word.i just know that rails talks a lot. for example, it needs at least a
‘show fields’ commands for each request. sessions slows the website
down unless you have memcache, which needs lots of RAM, so people
cannot use sessions for personal websites. i don’t know also where the
speed is lost, maybe in routes.rb, in dispatch …i don’t know.
There’s this concept I have called “tuning density”. It’s basically the
point at which changing the implementation of the design doesn’t buy you
any more performance, and the only thing left is to redesign. Even this
hits a certain tuning density when no design makes the application
faster, and the only thing left is to change to a faster platform. This
continues until you just cannot make it faster without a change in how
the universe works.
You can usually spot when you’re at the tuning density of a system when
the effort to increase it’s speed is greater than the performance gain
you get. At this point you have to look for alternative ways to make
the system faster or get deeper in the rabbit hole and do a complete
redesign.
I also say that tuning density is different from a bottleneck as it’s
not a single identifiable performance killer, but just a factor of how
the system is implemented. Changing it involves a complete rethinking
of the application so you’re stuck finding an alternative solution if
you can’t make the change.
My opinion is that Rails is at it’s tuning density. Folks like Stefan
Kaes and myself (indirectly) have been pounding on it in an attempt to
make it faster, but the effort just doesn’t match the gains. I think
this is a combination of two factors:
- Biggest limiting factor is that Rails isn’t thread safe, so it has
to be locked. Changing this though would involve a major redesign
(thus, it’s the current tuning density cause I think). - Ruby itself has such poor IO facilities and other processing limits
that only a magical complete rewrite or getting rails to run on
something else will improve things. I know most people yell and scream
that I’m an idiot when I point out the emperor has no clothes, but
remember I’m writing a web server AND client. The people yelling aren’t
even nearly as close to this as I am.
My suggestion right now is that you can’t do anything about the above
two short of getting in there and fixing the problem yourself or trying
your app on something like jruby or the latest ruby 1.9 vm.
What you must focus on–especially if your performance problem is
based on user perception–is how to make your application seem faster
to the users. This involves less mucking with code and more observation
and measurement of what users think. People are visually pretty dumb,
so you’d be amazed at what little stupid tricks you can do to simply
make them believe your stuff is quick.
Just remember, humans don’t have a stop watch embedded in the side of
their skull with nanosecond accuracy. For them, it’s how they think
about their experience that makes the difference.
Finally, I’d say that the most annoying thing I get from rails coders is
“potpourri turd syndrome” when it comes to performance. This is where
they assume whatever crap they slapped into their actions is golden and
smells like flowers, and therefore it must be [mongrel, ruby, rails,
etc.]. Before you go screaming at the performance of rails, do what I
did and quadruple check that it’s not your code messing things up or
running slow.
You wouldn’t believe how many times I’ve talked to someone with a
problem, and then upon looking at their code find out that they’re doing
something stupid. Not to mention, how many times I’ve had the same
person argue with me that their code is fine before finally having to
admit it’s crap.
Anyway, hope that gives some food for thought.
–
Zed A. Shaw
http://mongrel.rubyforge.org/
http://www.railsmachine.com/ – Need Mongrel support?