[SERVER-80986] Avoid calls to BSONObj::stripFieldNames in SortedDataIndexAccessMethod::findSingle Created: 12/Sep/23  Updated: 29/Oct/23  Resolved: 17/Oct/23

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

Type: Task Priority: Major - P3
Reporter: Mark Benvenuto Assignee: Gregory Noma
Resolution: Fixed Votes: 0
Labels: perf-tiger, perf-tiger-handoff
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution NAMER
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2023-10-30
Participants:

 Description   

In SortedDataIndexAccessMethod::findSingle, there is a call to BSONObj::stripFieldNames which walks the BSONObj and allocates a new one. For simple IDHack queries where _id is a scalar, this is unnecessary since field names are not stored in the keystring.

I do not know if this function can be omitted in all cases though as I am not very familiar with key string.

POC: https://github.com/10gen/mongo/commit/b2fe0cbb1697e55daa60991389e951bcc9eb8aed



 Comments   
Comment by Githook User [ 17/Oct/23 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-80986 Avoid copy in `SortedDataIndexAccessMethod::findSingle`
Branch: master
https://github.com/mongodb/mongo/commit/64155bc474f484913c3a43abdb246a4338d310fd

Comment by Gregory Noma [ 16/Oct/23 ]

I think the usage of BSONObj::stripFieldNames is actually already redundant here, because it looks like the key_string::HeapBuilder constructor already excludes the top-level field names here. In which case it should be safe to simply pass the original object without causing any behavioral changes.

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