Thursday, February 18, 2010

Post Modern Programming

Varnish is a reverse Web proxy cache. What makes it interesting is how it was designed. The argument is that people are programming like it's 1975, treating RAM and disk as two separate memory pools, instead Varnish views them as a single memory pool with the RAM acting just like a cache. It does this by mmap'ing a large file, the threads just read and write to this memory happily unaware that it is being backed to disk. This has the advantages of reduced complexity, no requirement to manage a RAM and disk cache, and also a lot less system calls (no read/write to disk). It also means that they have to use lots of threads because any memory operation could cause a thread to block because of a page fault - so they have a thread per connection model. This is contrary to how a lot of people develop these kinds of applications, they have an event driven system with only a couple of threads, or just one thread, and they focus on making sure that thread never blocks.

1 Comments:

Blogger kawaijen said...

"The argument is that people are programming like it's 1975"

In 1975, Multics had been doing already doing exactly that (mmapping disk objects)for quite a while (project started in 1964). So it is more a case of reinventing the wheel :-)

See wikipedia: "Multics implemented a single level store for data access, discarding the clear distinction between files (called segments in Multics) and process memory."

1:34 AM  

Post a Comment

<< Home