Good Reads, Technical

Tonight We’re Going to Program Like its 1975!

Interesting, enjoying, and even funny technical read from Poul-Henning Kamp: Architect Notes for the Varnish HTTP Accelerator

His big point is that programmers need to stop fretting over moving things between memory and disk themselves. He explains that on a modern computer system, RAM is backed by disk, and disk accesses are buffered in RAM, and a lot of work goes in to the kernel to ensure that the system behaves effectively. By managing your own RAM-or-disk conundrum, you end up making a mess of things, because when you go to move an unused “memory” object to disk, the kernel may already have paged the memory region to disk, and what happens is the object then must move from virtual memory on disk, to RAM, to a disk memory cache in RAM, and then back out to disk. It is simpler and more efficient to just ask for a big chunk of memory and let the kernel page things to disk for you.

He then explains some clever things you can do for multi-processor programming. It seems to boil down to trying to give threads their own stack space wherever practical, and managing worker pools as a stack, so that you are most likely to find yourself processing on the same CPU at the lowest level of cache, and least likely to need to pass memory variables between CPUs.

Not that I write multi-threaded applications, but if I ever do, I’ll try to keep this understanding in mind.

Read More

Categories: Good Reads, Technical

Discover more from dannyman.toldme.com

Subscribe now to keep reading and get access to the full archive.

Continue reading