MMAP Behind the Scenes in a Database Infino, an open-source search retrieval engine built by an engineer with three years of database experience, stores its data on S3 rather than local disk and runs at TB scale, using mmap only on immutable sealed segments written once with regular file I/O. The author argues that the common "you probably shouldn't" guidance on mmap (attributed to Andy Pavlo) misses that append-only write patterns eliminate mmap's dirty-page, flush-timing and crash-recovery hazards, since the write-ahead log handles durability for mutable data. The post documents the OS fundamentals behind mmap for database builders, noting the author still revisits kernel docs every few months for new edge cases. mmap behind the scenes in a database I have spent the last three years building databases. Two of them actually, both append only, both storing data at TB scale. The first one was a log analytics engine, essentially OpenSearch/Elasticsearch rewritten in Rust, something in the spirit of Lucene plus OpenSearch, tested against OpenSearch at similar latency at TB scale. The second one is a search retrieval engine I am building right now, full text, vector and SQL together, built to keep its data on S3 rather than on local disk, running at TB scale today and designed to go well past that. It is open source, at github.com/infino-ai/infino https://github.com/infino-ai/infino . mmap runs underneath both of them, and it has been the single most useful, most misunderstood, most under documented piece of systems knowledge I have had to pick up on the job. Three years in, I still go back to kernel docs every few months because some new edge case shows up. This post is me finally writing down everything I have learned, partly for myself, since this sat as a half finished draft for close to a year, and partly because I think the way most people talk about mmap in databases, quoting the famous “you probably shouldn’t” line Andy Pavlo in the house , misses an important nuance: it depends enormously on your write pattern, and append only changes the calculus completely. A bit about me first I’ve been building distributed systems at scale right from the start of my career, working at companies operating at real scale where I used databases like OpenSearch, RocksDB, Postgres and Redis in production and got curious enough to start reading their source code. That curiosity eventually led me to Infino, part time first, then full time. Why does an append only database even want mmap Let me start with the shape of the problem, because the shape of the problem is what makes mmap a good idea here and a bad idea somewhere else. An append only database never modifies data once it is written. New data comes in, gets buffered in memory, and once that buffer crosses some threshold it gets sealed into an immutable file on disk. Most engines, mine included, give this immutable file a name, a segment, and from here on I will just call it that. That sealed segment never changes again. If you want to update something, you write a new record, you do not rewrite the old one. Compaction, if you have it, reads a few segments and produces a brand new segment, it never edits an existing one in place either. This one property, immutability after write, is what makes mmap attractive instead of dangerous. A huge chunk of what makes mmap hard to use correctly in a general purpose transactional database simply does not exist for us: - there are no in place updates through the mapping, so there is no dirty page problem - there is no need to control exactly when a page gets flushed to disk, because nothing is ever flushed through the mmap in the first place, the file is written once with regular file I/O and only mmap’d after it is closed for serving queries - there is no crash recovery story that depends on mmap, because the write ahead log handles durability for the mutable, not yet sealed data, and mmap only ever touches immutable, already durable files Once a buffer is frozen into a file it becomes, from the mmap’s point of view, a read only blob. Querying it is exactly the kind of workload mmap was designed for: random access reads over a big file, without the process wanting to manage the buffering itself. Some OS basics before we go further If you already know what RAM, virtual memory, processes and interrupts are, skip straight to the next section, none of this will be new to you. I am putting this here because I remember my OS fundamentals getting blurry after college, and every explanation of mmap I found online assumed I still had them. RAM is a physical thing. Somewhere on the motherboard there is a bank of memory chips, DRAM, and that is the actual hardware that holds bytes while your machine is powered on. It has no idea what a file is, what a process is, or what a database is. It is just an enormous array of byte addresses that the CPU can read and write extremely fast, far faster than any disk. Everything else in this post is software built on top of that one piece of hardware. Disk is a different, much slower piece of hardware. SSDs and hard disks store data even when the machine is powered off, but reading from them, even a fast NVMe SSD, takes far longer than reading from RAM, often a hundred times longer or more. Nearly all of database performance engineering, at some level, is about the gap between how fast RAM is and how slow disk is, and about how much you can avoid touching disk on the hot path not even talking about object storage here . A process does not see physical RAM directly. Your operating system does not let a running program poke at physical memory addresses directly, for both safety and flexibility reasons. Instead every process gets its own virtual address space, a private range of addresses from the process’s point of view, that looks like it owns all the memory in the world. The CPU and the kernel work together to translate every virtual address a program uses into some real physical address in RAM, or realize it doesn’t have one yet. This translation is why two different processes can both think they own memory address, say, 0x7f0000000000 , and not be looking at the same physical byte at all. Memory is managed in fixed size chunks called pages , almost always 4 KB on Linux on typical hardware. RAM is carved into physical page frames of the same size. Virtual memory is carved into pages too. The mapping from a virtual page to a physical page frame lives in a data structure called the page table, one per process, maintained by the kernel and read by the CPU’s memory management unit on every single memory access. Kernel mode versus user mode is the other big idea worth having straight. Your database code runs in user mode, a restricted mode where it cannot directly touch hardware or other processes’ memory. The kernel runs in a privileged mode where it can. Whenever your program needs something only the kernel can do, open a file, read from disk, allocate memory, it has to ask, through a system call, which is a controlled, deliberate switch from user mode into kernel mode and back. Interrupts are how hardware talks to the CPU without the CPU having to constantly check on it. Here is a concrete example that matters a lot for mmap: say the kernel issues a read to an SSD to bring a block of data into RAM. That read takes time, thousands of CPU cycles worth of time. The CPU does not sit there spinning, waiting. It goes and does other work, runs other processes, other threads. When the SSD controller finishes the read and the data is sitting in RAM, ready, it signals the CPU using a hardware interrupt, an electrical signal on a dedicated line that says, roughly, “stop what you’re doing for a moment, something you were waiting on just finished.” The CPU pauses whatever it was running, jumps to a small piece of kernel code called an interrupt handler for that device, which notices the read completed, marks that data as ready, and wakes up whatever process or kernel thread was waiting on it. Interrupt driven I/O like this is what lets one CPU core juggle thousands of pending disk reads without wasting cycles polling each one. A page fault is a close cousin of an interrupt, but it is triggered by the CPU itself, not by a device, which is why it is sometimes called an exception or a trap instead. It happens synchronously, the instant an instruction tries to access a virtual address whose page table entry says “not present.” The CPU stops mid instruction, traps into the kernel’s fault handler, and hands off control exactly the same way a hardware interrupt would, except the trigger was “my own memory access just failed,” not “a device finished something.” This is the exact mechanism mmap depends on for everything that follows in this post, so it is worth having this picture in your head before we go on: touching mmap’d memory that is not yet resident triggers a CPU trap, the kernel’s handler figures out which file and offset that memory belongs to, issues a disk read if needed, gets woken up by a hardware interrupt when that read finishes, and only then lets your instruction actually complete. With those ideas, the rest of this post should read a lot more concretely. The basics: what actually happens when you call mmap Before getting into database specifics, it is worth being precise about what the kernel is doing, because I got this wrong for a long time and I see other engineers get it wrong constantly. The phrase “mmap loads the file into memory” is not right. mmap does not load anything. It reserves address space. When you call mmap NULL, len, PROT READ, MAP SHARED, fd, 0 , the kernel does roughly this: 1. It picks a range of virtual addresses in your process and marks that range as backed by this file, starting at this offset. This is a VMA, a virtual memory area, tracked in the process’s memory descriptor. 2. It returns a pointer to the start of that range. 3. That is it. No bytes are read from disk. No page of physical memory is allocated. The moment you actually dereference that pointer, say data 1000000 , the CPU tries to translate that virtual address to a physical address using the page table, and finds there is no page table entry yet, or one that is marked not present. The CPU raises a page fault, a hardware trap into the kernel. The kernel’s fault handler now has to figure out: this address belongs to a file backed VMA, at this particular offset in the file. It checks the page cache, the kernel’s cache of file backed pages that is shared across every process on the machine, to see whether that file’s page at that offset is already resident in memory. Two things can happen: - The page is already in the page cache maybe another process read it, maybe you read it earlier . This is a minor fault. The kernel just points your process’s page table at the existing physical page, no disk I/O needed. This is fast, microseconds. - The page is not in the page cache. This is a major fault. The kernel issues a read from the underlying block device, waits for it, populates a page cache page with the result, then points your page table at it. This can be milliseconds if you are unlucky and it is a cold read from spinning disk, hundreds of microseconds even off a fast NVMe SSD. Either way, once the page table entry is filled in, the CPU also caches that virtual to physical translation in the TLB, the translation lookaside buffer, a small hardware cache inside the CPU core, so the next access to that same page does not need a full page table walk. Your instruction that faulted gets retried transparently. You never see this happen. From your code’s perspective you just read a byte from an array. Underneath, potentially, a page fault, a page cache lookup, and a disk read all happened. Here is the part that made this click for me the first time I really understood it. This is exactly the buffer pool pattern that databases hand roll themselves, except the kernel is doing it for you, for free, and it is doing it for every file backed process on the machine, not just yours. The kernel mm docs https://docs.kernel.org/admin-guide/mm/concepts.html describe this well: the page cache exists specifically so that “recently used disk data is stored in RAM to avoid expensive disk access on subsequent reads.” mmap is just a way of exposing that cache directly into your address space instead of copying it into your own heap. Reclaiming memory, the part that took me the longest to understand This is the piece I struggled with the most, and the one that separates people who use mmap comfortably from people who are scared of it because of OOMs. Physical memory is finite. The kernel cannot keep every page you have ever touched resident forever. At some point it needs to take pages back. The kernel actually deals with two very different kinds of pages here, and the distinction matters a lot for anyone reasoning about this. There is anonymous memory, which is everything not backed by a file, your heap allocations, your stack, anything you got from malloc or a Vec growing in Rust. And there is file backed memory, pages that are a direct copy of some file’s contents, which is what a page cache page and an mmap’d page both are. The two behave completely differently under reclaim. Anonymous memory, once written to, has nowhere else in the world it exists. If the kernel wants that physical page back, its only option is to write it out to a swap device first, and swap is slow. It is why most production database boxes disable swap entirely rather than risk a query stalling on it. File backed pages are a different story, and this is the part that makes mmap cheap to reclaim. A file backed page is clean as long as nothing has modified it since it was read in. If you read only mmap a file, every single page behind that mapping is clean, always, by construction, since there is no write path through it at all. A clean page can be dropped by the kernel with zero I/O, no swap involved, because the exact same bytes are still sitting on disk where they came from. If you touch that address again later you simply take another fault and the kernel reads it back in from the file. This is the entire reason a read only mmap over an immutable segment is cheap for the kernel to manage under memory pressure: it is never looking at dirty anonymous pages that need a slow write out, only clean file backed pages it can throw away and re-fetch on demand. This is the mechanism that convinced me to stop worrying about memory management on the query side entirely. If I mmap a 50 GB segment and only ever read small slices of it per query, the kernel keeps hot pages resident and evicts cold ones under pressure, using an LRU-ish scheme across active and inactive lists, via kswapd running in the background when free memory drops below a watermark, or via direct reclaim in the calling process if memory pressure hits hard enough that there is no time to wait for the background thread. I do not write a cache eviction policy. I do not track which pages are hot. I do not size a cache and get that sizing wrong. The OS already has decades of tuning behind exactly this problem, and it is solving it for every process on the box at once, with a global view of memory pressure that a single process level cache could never have. That single idea, push page level memory management on the query path down to the OS and out of my own code, is the whole reason both my databases lean on mmap this heavily. But it is important to be precise about what part of the memory story this actually covers. It covers the file backed, non anonymous side, the mmap’d segments. It does not cover anonymous memory, the heap allocations a query makes while it runs, intermediate buffers, hash tables for a group by, vectors being collected for a result set. Nobody reclaims that for you. There is no disk backed copy of a hash map you built at query time, so the only way the kernel gets that memory back under pressure is the slow, swap based path we disable in production, or, if things get bad enough, the OOM killer ending your process entirely. So the two halves of memory need two different mindsets. Segment data behind mmap: let the OS manage it, do not build a cache for it, do not track it, do not fight the kernel. Anonymous memory a query allocates while it runs: that is still entirely your responsibility to bound, because the OS has no cheap way to take it back if you do not. This is exactly why Infino has an explicit memory budget for query execution https://github.com/infino-ai/infino/blob/main/src/memory/mod.rs and a ConnectionMemoryBudget that every allocation on the query path has to register against. Once a connection’s usage crosses its configured limit the query fails cleanly with an OverBudget error, instead of the process silently growing until the kernel OOM kills it. mmap gets you out of managing memory for the data you are reading. It does not get you out of managing memory for the work you are doing with it. Now, Andy Pavlo’s paper, and why append only sidesteps most of it I would be doing this topic a disservice if I did not bring up the elephant in the room. Andrew Crotty, Viktor Leis and Andy Pavlo’s CIDR 2022 paper, Are You Sure You Want to Use MMAP in Your Database Management System? https://www.cidrdb.org/cidr2022/papers/p13-crotty.pdf , is the most cited piece of writing on this exact topic, and it is a genuinely good paper. Its conclusion, roughly, is that mmap is a bad substitute for a hand rolled buffer pool in a general purpose transactional DBMS. The specific problems it raises: - page table contention: many threads faulting pages in and out of the same mapping serialize on kernel locks protecting page tables - TLB shootdowns: whenever the kernel unmaps or changes permissions on a page that another core has cached in its TLB, it has to send an inter processor interrupt to every core to invalidate that stale entry, which stalls those cores - single threaded page eviction under memory pressure , meaning the kernel’s own reclaim path becomes a bottleneck the DBMS cannot control or parallelize - crash recovery and transactional correctness: there is no way to control exactly when a dirty page gets written back to the file, and no cheap way to prevent a torn write from a half flushed page corrupting on disk state, which is a serious problem for a DBMS that needs strict control over write ordering for its recovery protocol - error handling: I/O errors on a memory mapped read do not come back as a return code you can check, they come back as a SIGBUS signal that will crash your process if you are not extremely careful about catching it Every one of these is a real problem if you are mmap’ing a file you intend to mutate through the mapping, concurrently, from many threads, while also needing strict write ordering for crash recovery. That describes a traditional row store with in place updates and ARIES style recovery almost exactly. It does not describe an append only, immutable segment store. Walk through the list again with that in mind: - crash recovery through mmap: does not apply, because nothing is ever written through an mmap in either of my databases. Recovery for the not yet sealed data is handled entirely by the write ahead log, using ordinary buffered append writes, O APPEND , write all , flush . mmap only sees files after they are closed and immutable. - torn writes and dirty page writeback ordering: does not apply, for the same reason. There are no dirty pages behind a read only mapping. A read only MAP SHARED mapping’s pages are never marked dirty by the kernel because nothing writes to them. - TLB shootdowns from mprotect/munmap churn: much less of an issue, because frozen segments are long lived, mmap’d once and kept mapped for the life of the segment, rather than being mapped and unmapped rapidly per query the way a naive implementation might. - single threaded eviction bottleneck: still theoretically present under heavy memory pressure, but a read mostly analytical workload with big sequential or clustered reads is exactly the workload eviction handles best, versus the highly randomized write heavy OLTP workload the paper is really worried about. - SIGBUS on I/O error: this one is real and I do not want to pretend otherwise. If the underlying file is truncated or the storage device fails mid read, you can get a SIGBUS . Handling this properly usually means either installing a signal handler or, more practically, being disciplined about the invariant that a frozen segment’s file never gets truncated or deleted while anything might still have it mapped. Both my codebases rely on that invariant rather than on catching the signal, mostly because in practice it has not bitten us given how segment lifecycle and garbage collection are sequenced. So Pavlo is right about the workload he is describing. My workload is a different workload. The paper’s own closing recommendation is roughly that mmap becomes reasonable for read only, low contention access patterns, which is precisely the frozen segment case. How this actually looks in the code Let me show the real thing instead of describing it abstractly. In the log analytics engine, every column of a segment, the inverted index postings list, the FST backed terms map, the forward map from doc id to source event, the range trees, time series and geo indexes, gets frozen the same way: serialize it to its own file, close the file, reopen it, and mmap it read only. js // postings list freeze path let file = tokio::fs::File::open &postings mmap path .await .map err |e| { CoreDBError::MmapError format "Failed to open postings list file: {:?}", e } ?; let mmap = unsafe { memmap2::Mmap::map &file .map err |e| { CoreDBError::MmapError format "Failed to mmap postings list file: {:?}", e } ? }; Some InvertedMapVariant::Frozen FrozenInvertedMap::new mmap, postings blob uncompressed size, Notice it is memmap2::Mmap::map , the immutable variant, never MmapMut . There is not a single MmapMut call anywhere in that crate. Every mapping is PROT READ , backed by an already closed file. The terms map is the one I find most satisfying, because the FST, the finite state transducer that backs prefix and range queries over terms, is built directly on top of the raw mmap bytes, with zero copies into a heap structure: js let mmap = unsafe { memmap2::Mmap::map &file .map err |e| { CoreDBError::MmapError format "Failed to mmap terms map fst file: {:?}", e } ? }; // We directly use the mmap to create the FST. let fst map = FstMap::new mmap .map err |e| CoreDBError::FSTError format "{:?}", e ?; That comment, “we directly use the mmap to create the FST,” is doing a lot of work. The FST library treats the mmap as a plain byte slice. It never knows or cares that the bytes underneath it might not even be resident in physical memory yet. Walking the FST to resolve a term touches a handful of bytes at a time, scattered across the file, each touch potentially a page fault, each fault resolved by the kernel without a single line of caching code written by us. The accounting comment right next to the memory usage calculation makes the intent explicit: // Add the memory usage of the frozen components which are not mmap'd and will be loaded // immediately into the memory. Read that carefully: mmap’d components are deliberately excluded from memory accounting. They are not “loaded into memory” from the process’s point of view, they are backed by the kernel’s page cache, and the kernel’s page cache is the kernel’s business, not ours. The write ahead log, on the other hand, has zero mmap in it, by design, since it backs the still mutable, not yet frozen segment: .append true // Open in append mode ... fn append &mut self, entry: &WriteWalEntry - Result< , CoreDBError { ... self.writer.write all &length prefix ?; self.writer.write all &serialized data ?; ... } pub fn flush &mut self - Result< , CoreDBError { self.writer.flush ?; ... } Plain buffered file writes, plain flush. Durability for live data comes from here, not from mmap. This split, WAL for live and mutable, mmap for frozen and immutable, is the entire architecture in one sentence. Because segments have to work whether the underlying storage is a local disk or S3, there is a helper layer that resolves an mmap path down to something local, downloading and caching from object storage transparently if needed: /// Returns a local file path for a file that will be used for mmap. /// /// If the underlying storage is Local then file path is assumed to be a local path. /// Otherwise, in cloud storage scenarios AWS, GCP, Azure , this function will look /// for a local cached copy under std::env::temp dir using file path as the key and, /// if it doesn't exist, downloads the file from the remote object store and writes /// it to that location. pub async fn get file for mmap &self, file path: &str, - Result< std::path::PathBuf, u64 , CoreDBError { self.get file for mmap internal file path, true .await } That comment is really the crux of the S3 story, which I want to go into properly next, because it applies even more to the newer, open source engine. Data lives on S3, disk is a cache, mmap is the layer above the cache Here is the part that took the mmap conversation from “nice trick” to “core architectural decision” for me. Both databases treat S3 as the actual source of truth, not local disk. Local disk is a cache in front of S3. And mmap is the layer that sits in front of that disk cache. So there are really three tiers stacked on top of each other: 1. S3 , durable, cheap, slow, the source of truth for every segment or superfile ever written 2. local SSD , a cache of the S3 objects that have recently been touched, populated lazily on first access 3. the page cache , backing an mmap over whatever is sitting in the local SSD cache, populated even more lazily, one page at a time, on actual read access Nothing is loaded eagerly at any of these three levels. A segment does not get downloaded from S3 until a query actually needs it. Once downloaded, it does not get read into memory until a query actually touches those specific bytes. This lazy loading all the way down is what makes it possible to have a query engine whose working set is far bigger than either the local disk cache or physical RAM, and still have it behave reasonably, because at every layer you are only paying for what you actually access. This is exactly the pattern in the newer open source engine, infino-ai/infino https://github.com/infino-ai/infino . Its disk cache layer, src/supertable/reader cache/disk/ , mmaps files that have been pulled down from S3 into the local cache: // src/supertable/reader cache/disk/ // SAFETY: file is owned by us; no other process modifies it let mmap = Mmap::map &file ?; What is different, and honestly better, about this second implementation compared to the older one is that it does not leave eviction purely to the kernel’s default page reclaim. It explicitly advises the kernel to drop cold pages once they age out past a configurable threshold: // src/supertable/reader cache/disk/budget.rs, idle sweep mmap.unchecked advise UncheckedAdvice::DontNeed It is driven by the config knobs mmap cold threshold secs and mmap sweep interval secs src/config/mod.rs , src/supertable/reader cache/config.rs . This is MADV DONTNEED under the hood, a hint that tells the kernel “you can drop these physical pages right now, I don’t need them resident, but keep the mapping valid, re-fault them from the file if I touch them again.” It is a way of proactively giving memory back rather than waiting for the kernel to notice pressure and reclaim on its own. Three years into this, adding that sweep is one of the concrete lessons carried from the first database into the second. Letting the kernel reclaim purely reactively works, but under bursty query load it can mean holding onto more resident memory than you’d like for longer than you’d like, and a periodic proactive sweep smooths that out. The vector index build path mmaps spilled intermediate files the same way, purely for zero copy chunked reads during a merge pass: // src/superfile/vector/spill.rs // Callers must ensure the spill file is not modified by another process, // only the build process owns the file let mmap = unsafe { Mmap::map &file ? }; And the full text search index builder does the same thing when merging sorted partitions: // src/superfile/fts/builder.rs // SAFETY: the sorted-partition scratch file is owned by this // builder's scratch dir ; no other process truncates or // appends to it for the lifetime of the Mmap . let mmap = unsafe { Mmap::map &f ? }; The multi process angle, which matters more as this engine grows up There is one more reason mmap matters for Infino’s engine specifically, beyond the S3 caching story, and it is about how we plan to deploy it in enterprise settings. The library is designed to be embedded, meaning a customer running it at real scale is not going to run a single process. They are going to run multiple worker processes on the same box, for isolation, for using more cores without fighting a single process’s internal concurrency limits, and for restart safety, so one worker crashing does not take the whole thing down. If every one of those worker processes had to load its own private copy of a segment into its own heap, memory would multiply linearly with worker count, which stops being viable fast once segments are large and worker counts climb. mmap avoids that multiplication almost by accident, as a side effect of how the page cache works. When two different processes mmap the same file with MAP SHARED , the kernel does not give them two independent copies of the data. It gives them two separate virtual address mappings that both point at the same physical pages in the page cache. The data is loaded into RAM once, no matter how many processes have it mapped. Read the code comments in the current implementation and you will notice the current assumption is single process ownership, “no other process modifies it.” That is correct for the write path today, only the process that built a file mmaps it as the owner while building. But nothing about read only MAP SHARED mmap prevents a second, third, or tenth process from separately opening and mmapping that same now immutable file and getting the exact same physical pages for free. That is the direction this is headed as the enterprise multi worker deployment model gets built out: workers share the physical memory backing a segment automatically, through the page cache, without a single line of shared memory IPC code, because the kernel is already doing this for any file two processes both happen to have mapped. This is, to me, one of the most underrated properties of mmap. Most conversations about mmap focus entirely on single process performance. The cross process sharing is arguably the bigger win once you are running a fleet of workers instead of one, and it comes essentially for free. What I would tell someone starting from zero If you are building something append only and you are wondering whether mmap is worth the trouble, the honest answer from three years of doing exactly this: it depends on whether you can honestly say your on disk files are immutable once written. If yes, most of the sharp edges people warn you about disappear, because those edges are really about mutation, not about mmap itself. If you still need in place updates, transactions across mutable pages, or fine grained control over write ordering for recovery, then Pavlo and Crotty’s warnings apply to you directly and you should probably build a real buffer pool. For everything else, mmap turns “how do I manage a cache of hot segment data across however many gigabytes or terabytes of cold data sits behind it” into a question the kernel has already spent decades answering well. That has been worth the occasional confusing afternoon reading /proc/PID/smaps or staring at kernel source trying to understand exactly when a page gets reclaimed. References - Are You Sure You Want to Use MMAP in Your Database Management System? https://www.cidrdb.org/cidr2022/papers/p13-crotty.pdf , Andrew Crotty, Viktor Leis, Andy Pavlo, CIDR 2022 - Linux kernel memory management concepts https://docs.kernel.org/admin-guide/mm/concepts.html - mmapbench https://github.com/viktorleis/mmapbench , the benchmark accompanying the CIDR 2022 paper - infino-ai/infino on GitHub https://github.com/infino-ai/infino , the open source search retrieval engine referenced throughout this post - memmap2 crate documentation https://docs.rs/memmap2 , the Rust mmap wrapper used in both codebases discussed here - The good old man pages https://man7.org/linux/man-pages/man2/mmap.2.html If you have reached this far, please consider giving our open source repo infino-ai/infino https://github.com/infino-ai/infino a star on GitHub.