[SERVER-8927] Add a new administrative command to provide statistics about the memory cache of all documents in a collection Created: 10/Mar/13 Updated: 14/Mar/17 Resolved: 04/Jun/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Diagnostics |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Benedikt Waldvogel | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
The command is helpful but can be misleading if one is interested in how many documents of a collection are in memory (cached). Example of pagesInRAM()Given collection with "nrecords" : 155219, "deletedCount" : 80617.
The output of db.coll.getPagesInRAM() is the following:
Still, all documents are in memory although the output might be interpreted differently. documentsInRAM()I propose to add a subcommand documentsInRAM, that doesn't scan extents, but uses the id index to scan through all non-deleted documents and check if they are in memory. Furthermore, the command can output an estimate of memory fragmentation caused by the page-structure of virtual memory. Example of documentsInRAM()
All documents are fully in memory ("inMem" : 1.0). The memory fragmentation is only about 2.5% since the overhead caused by virtual memory paging (pageBytesInRAM - netBytesInRAM) is low in this case. |
| Comments |
| Comment by Benedikt Waldvogel [ 07/Jun/13 ] |
|
Yes, the index needs to be in RAM in order to achieve an accurate measurement. I should have mentioned that in the description. The ticket was closed as "Won't Fix". But is there an alternative to measure memory fragmentation or the amount of RAM to hold all non-deleted documents in memory? |
| Comment by Eliot Horowitz (Inactive) [ 04/Jun/13 ] |
|
The problem with anything like this is that by looking at the documents (in your case reading the _id index) you change what's in ram, making the measurement not terribly accurate. There are other tickets about doing it via extents, which I think is the correct method.
|
| Comment by Benedikt Waldvogel [ 10/Mar/13 ] |
|
My pull request https://github.com/mongodb/mongo/pull/392 adds the command documentsInRAM() as proposed in the description. |