[DOCS-13943] Investigate changes in SERVER-40361: Reduce memory footprint of plan cache entries Created: 22/Oct/20  Updated: 13/Nov/23  Resolved: 22/Mar/21

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.9.0, 4.2.12, 4.4.3, 4.0.23, 3.6.23, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Naomi Pentrel (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
backported by DOCS-14004 [BACKPORT] [v4.4] Reduce memory footp... Closed
backported by DOCS-14080 [BACKPORT] [v4.2] Reduce memory footp... Closed
backported by DOCS-14166 [BACKPORT] [v4.0] Reduce memory footp... Closed
backported by DOCS-14172 [BACKPORT] [v3.6] Reduce memory footp... Closed
Documented
documents SERVER-40361 Reduce memory footprint of plan cache... Closed
Participants:
Days since reply: 2 years, 43 weeks, 6 days ago
Epic Link: DOCSP-9747
Story Points: 2

 Description   

Description

Downstream Change Summary

There is a new setParameter 'internalQueryCacheMaxSizeBytesBeforeStripDebugInfo'. Its default value is 0.5 GB. The operator can increase the value of the parameter to allow more debug information to be stored in the plan cache, or reduce its value to save memory. By setting it to zero, no debug information will be stored alongside new plan cache entries.

When the debug info for a plan cache entry has been stripped, $planCacheStats will return an entry that has the fields "queryHash", "planCacheKey", "isActive", "works", "timeOfCreation", "indexFilterSet", and "estimatedSizeBytes", but it will be missing the fields "createdFromQuery", "cachedPlan", "creationExecStats", and "candidatePlanScores". Note that "estimatedSizeBytes" is a new field which displays the estimated size in bytes of each plan cache entry.

For documentation purposes, I'm not sure that we should document 'internalQueryCacheMaxSizeBytesBeforeStripDebugInfo', since hopefully the default will be appropriate for most applications. However, we should document the addition of the "estimatedSizeBytes" field to the $planCacheStats output.

Description of Linked Ticket

For some workloads, the per-collection query plan caches can consume too much memory. SERVER-34886 and SERVER-40360 together describe an architectural solution to this problem: turn the per-collection plan caches into a process-global plan cache, and bound the size of this new global cache in bytes rather than number of entries.

However, we could also reduce the memory footprint of the plan cache by auditing the debug information it holds in memory. We have observed in the field that this problem is most severe when the user runs large queries; this can result in the information held in the plan cache for introspection taking up a lot of memory. Perhaps this debug information can be truncated if it exceeds some threshold, in order to reduce the amount of debug information present in exchange for avoidance of excessive memory consumption.

The suspected worst offenders are:

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Githook User [ 08/Apr/21 ]

Author:

{'name': 'Naomi Pentrel', 'email': '5212232+npentrel@users.noreply.github.com', 'username': 'npentrel'}

Message: DOCS-13943 Add plan cache limit and stats
Branch: v3.6
https://github.com/mongodb/docs/commit/0c38fcb1187275ad85aef74d282c3320458c2b76

Comment by Githook User [ 07/Apr/21 ]

Author:

{'name': 'Naomi Pentrel', 'email': '5212232+npentrel@users.noreply.github.com', 'username': 'npentrel'}

Message: DOCS-13943 Add plan cache limit and stats
Branch: v4.0
https://github.com/mongodb/docs/commit/a703c2afbfa570f71165660af468cb318c85015d

Comment by Githook User [ 25/Mar/21 ]

Author:

{'name': 'Naomi Pentrel', 'email': '5212232+npentrel@users.noreply.github.com', 'username': 'npentrel'}

Message: DOCS-13943 Add plan cache limit and stats
Branch: v4.2
https://github.com/mongodb/docs/commit/cac9ed5382b3fb68f4980fecff48866c407ad814

Comment by Githook User [ 23/Mar/21 ]

Author:

{'name': 'Naomi Pentrel', 'email': '5212232+npentrel@users.noreply.github.com', 'username': 'npentrel'}

Message: DOCS-13943 Add plan cache limit and stats
Branch: master
https://github.com/mongodb/docs/commit/580ecd1af63e6301c50b0f9e9e934fe57bd64217

Comment by Githook User [ 23/Mar/21 ]

Author:

{'name': 'Naomi Pentrel', 'email': '5212232+npentrel@users.noreply.github.com', 'username': 'npentrel'}

Message: DOCS-13943 Add plan cache limit and stats
Branch: v5.0
https://github.com/mongodb/docs/commit/6f93ed1ad3911a779436eb059a77b37fcb4dc554

Comment by David Storch [ 05/Jan/21 ]

See my comment here in SERVER-40361 for a note about how 4.2 version of this change differs from the 4.4+ version. Namely, in 4.2 there are consequences for the planCacheListQueryShapes and planCacheListPlans commands. In 4.4, in contrast, these commands do not exist, since they were deprecated in 4.2 and removed in 4.4.

Generated at Thu Feb 08 08:09:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.