There are cases when it would be very useful to be able to see what the cache looks like. It'd be nice if we could expose that via the statistics cursor API. Something like:
session->open_cursor(session, "statistics:cache:", NULL, NULL, &cursor)
I'm not sure how the information would be best returned. Possibly each page in the cache gets a set of statistics including:
- Page type
- Memory footprint
- URI of file it belongs to
- Dirty size
- Number of deleted entries
- Flags settings
- Number of entries
- Number of updates for leaves
- Number of children for internal pages
- How many overflow references there are on the page
- Whether there are overflow keys
- Whether the page has been split
- Whether the page was created in memory or has a backing disk image
It would be expensive to gather this information, and somewhat difficult due to the system changing while walking the in-memory tree. It could be very helpful in diagnosing issues related to eviction and cache usage.
Ideally it would be possible to correlate parent/child relationships. Maybe print out a parent reference identifier and an identifier for each page being dumped.
There is a function called
in
src/eviction/evict_lru.c{{`}} that walks in-memory pages and dumps cache information to disk - it could be a starting point.
A search on such a cursor would probably be a no-op, only traversal would be allowed.