11 ms·
So what happens with squids elaborate memory management is that it gets into fights with the kernels elaborate memory management, and like any civil war, that n
by coffeemug 14y ago
So what happens with squids elaborate memory management is that it gets into fights with the kernels elaborate memory management, and like any civil war, that never gets anything done.
This quote, much like various scientific quantum mechanics quotes adopted by the laymen, keeps haunting honest systems programmers because people with a little bit of knowledge read it, misinterpret (or misunderstand) it, and then share it.
Look, I don't know how Squid is designed, but most database systems use this strategy and it does not get into wars with the kernel for a whole slew of reasons that aren't addressed in the article. I know, because we've done a ton of sophisticated benchmarking comparing custom use case cache performance to general purpose page cache performance. Here are a few of the many, many reasons why this quote cannot be applied to sensibly designed pieces of systems software:
1. If the database/proxy/whatever server is designed correctly, it'll always use just enough RAM that it won't go into swap. That means the kernel won't magically page out its memory preventing it from doing its job.
2. In fact, kernels provide mechanisms to guarantee this by using various mechanisms (such as mlock).
3. Also, if your process misbehaves, modern kernels will just deploy the OOM killer (depending on how things are configured), so you can't just get into fights with the page cache without being sniped.
4. Of course you have to be smart and read from the file in a way that bypasses the page cache (via DIRECT_IO). Yes, it complicates things greatly for systems programmers (all sorts of alignment issues, journal data filesystems issues, etc.) but if you want high performance, especially on SSDs, and have special use cases to warrant it, it's worth it.
5. If you really know what you're doing, a custom cache can be significantly more efficient than the general purpose kernel cache, which in turn can make significant impact on performance bottom line. For example, a b-tree aware caching scheme has to do less bookkeeping, is more efficient, and has more information to make decisions than the general purpose LRU-K cache.
In fact, it is absolutely astounding how many 1975 abstractions translate wonderfully into the world of 2012. Architecturally, almost everything that worked back then still works now, including OS research, PL research, algorithms research, and software engineering research -- the four pillars that are holding up the modern software world. Some things are obsolete, perhaps, but far, far fewer than one might think.
Incidentally, this is also one of the reasons why I cringe when people say "the world is changing so fast, it's getting harder and harder to keep up". In matters of fashion, perhaps, but as far as core principles go (in computer science, mathematics, human emotions/interaction, and pretty much everything else of consequence) the world is moving at a glacial pace. Shakespeare might be a bit clunky to read these days because the language is a bit out of style, but what Hamlet had to say in 1600 is, amazingly, just as relevant today (and likely much more useful, because instead of actually reading Hamlet, most people read things like The Purple Cow, The 22 Immutable Laws of Marketing, The 99 Immutable Laws of Leadership, etc.)
- marshray 14y agoI'd say the kernel going on a shooting spree wherein the OOM kill starts taking out innocent processes as they touch memory pages they were legitimately allocated is a perfect example of "getting into wars with the kernel".
- coffeemug 14y agoMy point was that (a) if the server actually goes to war with the kernel, on modern setups it will usually be taken out by the OOM killer instead of just getting slower like the article states, and (b) most database servers run just fine without being taken out by the OOM killer, which means they're designed in a way that actually does not go to war with the kernel.
- marshray 14y agoGood point. Wars between userspace processes and the kernel are very short.
- ChuckMcM 14y agoAs others have noted the rant is from 2008, which is interesting because this was the transition point between wide spread adoption of 64 bit aware OSes from 32 bit aware OSes [1]. You can see lots of folks who are just getting their feet wet with 64 bit Linux [2], and configured memory sizes are getting up over 4GB 'real' memory. One of the wonderful things about 64 bit address spaces? You don't ever have to re-use an address. Once folks figure that out you can do some amazing things that would have seemed stupid in the 70's, you can hard code the address for every single library function on your machine. Can you even imagine how weird that would be? Linking time would be instantaneous, calling printf? its always at 0x10015081aaf10000, all of libc? starting at 0x1000000000000 and working up. One giant database of the 'standard place' to put every single function. Remember when the 32 bit OS would put the kernel at 0x80000000 ? You know right on the 2G border, above that, kernel space, below that user space. Anyway, I completely concur that abstractions that worked before, work wonderfully today. But I also don't worry about an array of 100M items on a server in RAM anymore. Using mmap to map a 1G file into the address space? Not a problem. Its interesting to watch the behavior of systems when they are essentially all in memory. [1] http://www.tomshardware.com/reviews/vista-workshop,1775-3.html http://www.tomshardware.com/reviews/vista-workshop,1775-3.ht... [2] http://blekko.com/ws/?q=64+bit+linux+%2Fdate%3D2008 http://blekko.com/ws/?q=64+bit+linux+%2Fdate%3D2008