|
|
|
|
|
by 10000truths
1614 days ago
|
|
You don't want the OS to take care of reading from disk and page caching/eviction. You want the DB itself to have explicit control over that, because the DB has information on access patterns and table format that the OS is not aware of. It is better equipped than the OS to anticipate what portions of tables/indices need to be cached in memory. It is better equipped to calculate when/where/what/how much to prefetch from disk. It is better equipped to determine when to buffer writes and when to flush to disk. Sure, it might be more work than using mmap. But it's also more correct, forces you to handle edge cases, and much more amenable to platform-specific improvements a la kqueue/io_uring. |
|
You are correct to an extent, but there are a few things yo noted.
* you can design your system so the access pattern that the OS is optimized for matches your needs
* you can use madvise() to give some useful hints
* the amount of complexity you don't have to deal with is staggering