[SERVER-62774] Avoid copying DebugInfoSBE when recovering a plan from the SBE plan cache Created: 19/Jan/22  Updated: 29/Oct/23  Resolved: 29/Mar/22

Status: Closed
Project: Core Server
Component/s: Query Planning
Affects Version/s: None
Fix Version/s: 6.0.0-rc0

Type: Task Priority: Major - P3
Reporter: David Storch Assignee: Anton Korshunov
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Sprint: QO 2022-04-04
Participants:
Linked BF Score: 0

 Description   

Each entry in the SBE plan cache, in addition to the cached SBE plan itself, holds some debug info that is necessary to correctly populate the logs, system.profile, and so on. At the moment, when a query uses a cached plan, it will copy the debug info out of the cache. I believe that copy happens here.

Since the debug info is read-only, theoretically all queries using a cache entry could share the same DebugInfoSBE object rather than making their own copy. They can't just keep a reference or raw pointer, because after looking up the entry in the cache, that plan cache entry could subsequently be evicted and the reference/pointer would become invalid. Instead, each query could hold the debug info by std::shared_ptr. That way, the lifetime of the debug info would be extended after the corresponding plan cache entry is destroyed until all queries relying upon the debug info complete.



 Comments   
Comment by Githook User [ 29/Mar/22 ]

Author:

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

Message: SERVER-62774 Avoid copying DebugInfoSBE when recovering a plan from the SBE plan cache
Branch: master
https://github.com/mongodb/mongo/commit/80d15266187e5c83ab8202e8baa2774814cc91d2

Generated at Thu Feb 08 05:56:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.