A common confusion point is that “MongoDB is an in-memory DB”. Mongo maps to virtual memory: doesn’t need to fit in RAM. Now he’s showing a diagram of virtual address space: kernel space, stack, heap, program text, etc. Program text is mmap’ed just like Mongo data files. Showing where the mapped data files live in the virtual address space."
What is the program text ,and what does "Program text is mmap’ed just like Mongo data files. Showing where the mapped data files live in the virtual address space" mean ?
thank you !
Memory mapping is what the operating system does (Windows does it, I'm pretty sure linux does it too) when it loads your binaries. The binaries themselves could be called "program text". Hence, all .exe
and .dll
files are essentially memory-mapped. The message here is: if you can trust the OS to do memory-mapping for it's core purpose of allowing other binaries to execute, you can also trust it to map data files of your database, which is what MongoDB does.
All this has nothing to do with 'in-memory db', because memory-mapping is "just" a fancy way to coordinate file access through the OS.
It also explains that both binaries and data reside in the same memory, which is what I recall to be one of the most important contributions by Konrad Zuse to the early days of computing: Programs and data don't sit in different physical memories, because there is no fundamental difference between them.