As If You Needed Another Reason to Have an LWN Subscription
Run, don’t walk, over to LWN to read the first article in new series by Ulrich Drepper entitled What every programmer should know about memory. It is very detailed and well written: in other words, the kind of content I always expect when I wander over to LWN. They are an outstanding group producing quality work for far too little money, so I encourage anyone who doesn’t have a subscription to get one (as little as $2.50/month). Sure, you could wait for Ulrich’s article to be released and read it for free, but if you sign up you can read it and content like it a week before everyone else and know that you are supporting this kind of quality work.
Ruby on Rails Memory Efficiency 7
Okay, I said I suspected that Ruby wasn’t terribly memory efficient yesterday. Today I have some strong indications that at least Typo isn’t quite so memory efficient.
I had noticed that my blog was getting quite slow and handling updates, and it wasn’t clear to me why. I am particularly sensitive to efficiency issues, because I run this whole thing inside a User Mode Linux instance, which imposes it’s own inefficiencies on pretty much all aspects of the Linux kernel. So I generally have to be fairly careful to tune everything I run inside it to minimize kernel involvement. I was all ready to blame UML again until I looked at what was going on with the instance: it was swapping like crazy.
Some peaking around in the system showed working set sizes for my Ruby FastCGI processes in the 35MB-50MB range (very bad considering my instance only has 64MB of RAM allocated for it) –that’s the kind of footprint that makes you start to think of J2SE/EE! To get an idea of how inefficient that is, Postgres’s working set size for handling this puny blog is about 4-5MB.
So far, I’ve been able to get back to some kind of decent performance by trimming my FastCGI process count down to one (which has some unfortunate side effects, but none as unfortunate as having 20-30MB of memory constantly swapping).
This tweaks my curiosity as to what’s going on under the covers, and how much of the overhead is Ruby, how much is Rails, and how much is Typo.