Skip to content

Commit 52c8d95

Browse files
author
Sam Kleinman
committed
storage FAQ edits and revisions
1 parent 7d8c302 commit 52c8d95

File tree

1 file changed

+39
-50
lines changed

1 file changed

+39
-50
lines changed

draft/faq/storage.txt

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,30 @@ the :doc:`complete list of FAQs </faq>` or post your question to the
1515
:backlinks: none
1616
:local:
1717

18-
What are Memory Mapped Files?
18+
What are memory mapped files?
1919
-----------------------------
2020

21-
Memory mapped files are segments of virtual memory which have been
22-
assigned a direct byte-for-byte correlation with some portion of a
23-
file or resource. Once present, this correlation between the file and
24-
the memory space permits applications to treat the mapped portion as
25-
if it were primary memory.
21+
Memory mapped files are segments are a way of keeping files and data
22+
up to date in memory using the system call ``mmap()``. MongoDB uses
23+
memory mapped files as its storage engine. By using memory mapped
24+
files MongoDB can treat the content of its data files as if they were
25+
in memory. This provides MongoDB with an extremely fast and simple
26+
method for accessing and manipulating data.
2627

27-
How does memory-mapped file access work in MongoDB?
28-
----------------------------------------
28+
How do memory mapped files work?
29+
--------------------------------
2930

30-
MongoDB uses memory-mapped files for memory management.
31+
Memory mapping assigns files to a block of virtual memory with a
32+
direct byte-for-byte correlation. Once mapped, the relationship
33+
between file and memory, allows MongoDB to interact with the data in
34+
the file as if it were memory.
3135

32-
MongoDB memory maps the files when they are first accessed; you're
33-
letting the OS know you'd like the contents of the files available as
34-
if they were in some portion of memory. It should be noted that each
35-
OS caches its own components in memory, and also provides memory
36-
buffers for network connections and disk drivers in addition to
37-
applications.
38-
39-
This doesn't necessarily mean the files are in memory already-- when you go to
40-
access any point, the OS checks if this 'page' is in physical ram or
41-
not.
42-
43-
If the page is already in memory, it returns whatever's in memory in
44-
that location. If the page is not in memory, then it will fetch that
45-
portion of the file, make sure it's in memory, and then return it to
46-
you.
47-
48-
Writing works in the same fashion-- MongoDB tries to write to a memory
49-
page. If the page is in RAM, then it works quickly (just swapping some bits
50-
in the memory). The page will then be marked as 'dirty' and the OS
51-
will take care of flushing it back to disk, persisting your changes.
36+
How does MongoDB work with memory mapped files?
37+
-----------------------------------------------
5238

39+
MongoDB uses memory mapped files for managing and interacting with all
40+
data. MongoDB memory maps data files to memory as it accesses
41+
documents. Data that isn't accessed is *not* mapped to memory.
5342

5443
What are page faults?
5544
---------------------
@@ -65,32 +54,32 @@ load it into RAM...an expensive task, overall.
6554
What is the difference between soft and hard page faults?
6655
---------------------------------------------------------
6756

68-
A page fault implies a "hard" page fault, which requires disk access.
69-
A "soft" page fault merely moves memory pages from one list to
70-
another, and is not as expensive.
57+
:term:`Page faults <page fault>` occur when MongoDB needs access to
58+
data that isn't currently in active memory. A "hard" page fault,
59+
refers to situations when MongoDB must access a disk to access the
60+
data. A "soft" page fault, by contrast merely moves memory pages from
61+
one list to another, and does not require as much time to complete.
7162

7263
What tools can I use to investigate storage use in MongoDB?
7364
-----------------------------------------------------------
7465

75-
There is a command whose output provides the current state of the
76-
"active" database, see :doc: 'Database Statistics Reference
77-
</reference/database-statistics>'.
66+
The :func:`db.stats()` function in the :program:`mongo` shell, will
67+
output the current state of the "active" database. The
68+
:doc:`/reference/database-statistics` document outlines the meaning of
69+
the fields output by :func:`db.stats()`.
7870

7971
What is the working set?
8072
------------------------
8173

82-
The working set is an approximation of the set of pages that a certain
83-
process will access in the future (say, during the next 't' time
84-
units), and more specifically is suggested to be an indication of what
85-
pages ought to be kept in main memory to allow most progress to be
86-
made in the execution of that process.
87-
88-
A common misconception in using MongoDB is that the working set can be
89-
reduced to a discrete value. It's important to understand that the
90-
working set is simply a way of thinking about the data one is
91-
accessing and that which MongoDB is working with frequently.
92-
93-
For instance, if you are running a query that has to do a full table
94-
scan, then your working set is every document scanned. Conversely, if
95-
your query only reads the most recent 100 documents, then the working
96-
set will be those 100 documents.
74+
Working set represents the total body of data that the application
75+
uses in the course of normal operation. Often this is a subset of the
76+
total data size, but the specific size of working set depends on
77+
actual moment-to-moment use of the database.
78+
79+
If you run a query that requires MongoDB to scan every
80+
:term:`document` in a collection, the working set includes every
81+
document in memory.
82+
83+
For best performance, the majority of your *active* set should fit in
84+
RAM.
85+

0 commit comments

Comments
 (0)