3 ms·
TLDR; Varnish is very proud they use memory-mapped files for cache, instead of managing RAM and disk cache separately. That said, don't overestimate the OS abi
by slver 5y ago
TLDR; Varnish is very proud they use memory-mapped files for cache, instead of managing RAM and disk cache separately.
That said, don't overestimate the OS ability to understand your usage of RAM. The entity with highest insight on that usage is the application.
Maybe there's some fortunate overlap in the case of a caching service (Varnish) using a caching service (OS disk cache / virtual memory). Varnish itself has little clue how their entries will be used beyond what the OS sees.
But in more complex applications that's decidedly not the case. Photoshop for example to this day uses a "scratch disk" separate from virtual memory. In fact you better hope you never use swap file with Photoshop, because it becomes unusable.
- hughw 5y agoThanks for making this point. If you access your memory sequentially, as Varnish does, great. But if you need to stride across a giant matrix in transposed order, you'll bring your spinning disk backed virtual memory to a halt, as it does a million seeks. To use virtual memory successfully you have to write in-memory algorithms that recognize the non-random-access nature of the memory. If you had simply acknowledged there's a storage system, you wouldn't put out much more effort, if any, to get the same performance. In fact, by pretending it's all RAM, you give up the opportunity to overlap your I/O and do something useful with the time the system would have to spend paging in your data. Edit: btw, happy and satisfied Varnish user for many years!