3 ms·
SQLite does not use mmap as a main I/O mechanism by default, it provides it as an optional feature [1]. mmap has one large advantage, which is that it allows y
by mytherin 4y ago
SQLite does not use mmap as a main I/O mechanism by default, it provides it as an optional feature [1].
mmap has one large advantage, which is that it allows you to share buffers with the operating system. This allows you to share buffers between different processes, and allows you to re-use caches between restarts of your process. This can be powerful in some situations, especially as an in-process database, and cannot be done without using mmap.
There are many problems with using mmap as your only I/O and buffer management system (as listed in the paper and the SQLite docs). One of the main problems from a system design perspective is that mmap does not enforce a boundary on when I/O occurs and what memory to manage. This makes it very hard to switch away from mmap towards a dedicated buffer pool, as this will require significant re-engineering of the entire system.
By contrast, adding optional support for mmap in a system with a dedicated buffer pool is straightforward.
[1] https://www.sqlite.org/mmap.html https://www.sqlite.org/mmap.html