Whuut?!

Monday, April 20, 2009

How low can mem go?

I just read How Slow Can Linux Go over at Computer World.

One thing I never get when people are discussing underpowered systems and lightwheight systems, is why RAM size is so horribly overlooked? Since when is 1gig of ram not plenty? Even many linux-apps completely suck at ram usage.

Pidgin is an excellent example. What is it's purpose? Displaying a list of buddies, which you can contact, see availability, history, and some other miscellaneous functions. How much ram should we expect to see from that app?

Let's break it down:
First: Data
Pixmaps
Pidgin would probably want to ram-cache your buddy-icons. Let's assume we want to support a decent size of buddy-icons, 64x64. Times 32-bit color-depths (with alpha), we get 16K/icon. Assume we've got 512 buddies (yeah, we're popular), and we get 8 MB of ram for this.
History Index
We of course want quick access to our history without chewing all disk. I'm not sure exactly how to correctly assess the requirements here, but let's assume you've got 128K messages in your history, and that each index entry takes up 8 bytes and that the structure consumes twice as much space as needed = 2MB.
Other
Pidgin probably needs to map some fonts, some internal structures for availability, some text about your buddy details, some icons for own buttons etc. as data, so let's guess that everything else takes as much as history and data combined.
Summary
With the above mentioned naive guestimates, we would expect Pidgin to hold some 20MB of data in memory. My pidgin right now consumes 77MB, almost 4 times the size. Complete resident set-memory is 33MB, well over 50% more than the above can see a realistic need for.
Also, remember that the above examples is probably exagerated on the large side. Pixmaps could probably compressed a couple of times in ram (and there certainly isn't 512 buddies in my list), the history-index doesn't really need to be in ram, and the other stuff could probably be optimized/compressed down to maybe 4MB easily.

Next: Shared Memory (or lack of)
Here is where Pidgin, as most Linux-apps sadly really fails. Exploring /proc//maps, we really see a LOT of libs and resources that COULD be shared by other processes. All in all, no less than 50MB is mapped files. The vast majority of these files are common stuff, libSASL, Xlib, gstreamer, and /usr/share/icons/hicolor/icon-theme.cache. However, sadly only 1/5 of these memory is marked as shared by in top.

Grand Finale
If there's one thing I have a hard time accepting is sloppy coding "since hardware is cheap". I want to buy new hardware to get BETTER performance. Not do a hardware upgrade just to match the same performance I had before the last software "upgrade".

0 Comments:

Post a Comment

<< Home