[SERVER-73659] Account for size of KVMap in LRUKeyValue cache memory budget tracking Created: 06/Feb/23  Updated: 24/May/23  Resolved: 27/Apr/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Maddie Zechar Assignee: Backlog - Query Optimization
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-73649 Improve SBE plan cache BudgetEstimato... Closed
related to SERVER-76622 Complete TODO listed in SERVER-73659 Closed
related to SERVER-76769 Complete TODO listed in SERVER-73659 Closed
related to SERVER-76574 Improve LRUKeyValue to avoid storing ... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

With changes from SERVER-71882, the size of the BSON key and telemetryMetrics value are included in LRUKeyValue memory tracking. However, the size of KVMap, which holds a int_32 hash of the cache keys and pointers to the associated key's position in KVList, should also be included in memory tracking. 

 

LRUKeyValue should maintain its own budge tracker for this overhead cost. It might make sense to replace the estimator from LRUBudgetTracker with a lambda:

template <typename K, typename V>
class LRUBudgetTracker {
public:
LRUBudgetTracker(size_t maxBudget) : _max(maxBudget), _current(0) {}
void onAdd(const K& k, const V& v, std::function<size_t(const K&, const V&)> estimator)
{ _current += estimator(k, v); } 

This would call the estimator defined in LRUKeyValue which would have a flag for including overhead size or not in total size. In case of classic plan cache, we only want to know number of entries. We do not care about the size of the keys, size of the plans, or size of overhead. However, we do care about size of overhead for SBE plan cache and telemetry.



 Comments   
Comment by Githook User [ 24/May/23 ]

Author:

{'name': 'Anton Korshunov', 'email': 'anton.korshunov@mongodb.com', 'username': 'antkorsh'}

Message: SERVER-76769 Complete TODO listed in SERVER-73659
Branch: master
https://github.com/mongodb/mongo/commit/ec7fbab0ecdbe68bcfbadc3dff5f91d3c5782119

Comment by David Storch [ 26/Apr/23 ]

Marking this for re-triage. I filed SERVER-76574 about avoiding storing keys twice in LRUKeyValue. SERVER-73649 tracks the work to actually account for the size of the key in the plan cache budget estimators.

I believe that we can close this ticket as "Won't Fix". While we could account for the overhead of LRUKeyValue::_kvMap, I'm not sure that we really need to do so. It seems sufficient if the sum of the size estimates of the (key, value) pairs stored within the data structure fit within the budget.

If we do decide not to do this ticket, note that there is a "TODO" comment in the code base that needs to be cleaned up before this ticket is resolved.

Comment by Anton Korshunov [ 15/Feb/23 ]

See this comment.

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