Hacker News new | ask | show | jobs
by bminor13 2286 days ago
A minor note in the article reads:

> To minimize I/O and take advantage of operating system caching, csearch uses mmap to map the index into memory and in doing so read directly from the operating system's file cache. This makes csearch run quickly on repeated runs without using a server process.

Does anyone know some resources where I can read more about this technique? (how-to, pros/cons, caveats, etc.) I'm interested in figuring out the best way to have a commandline tool persist state that it can quickly access across multiple runs, but so far a background server process is the only technique I'm familiar with.

1 comments

Yeah, you have to run a server. When a process exits, all its mmap'd pages are reclaimed. Just like any other memory.
But this excerpt says that this technique obviates the need for a server process? Are they saving the contents of memory into files using mmap, and then using this state on every run?
I just reread your quoted passage and noticed the reference to the OS's file cache. Ok, this is outside my knowledge :)