[SERVER-86119] Speed up BSONObj::getField Created: 02/Feb/24  Updated: 07/Feb/24  Resolved: 07/Feb/24

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

Type: Improvement Priority: Major - P3
Reporter: Geert Bosch Assignee: Geert Bosch
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2024-02-19
Participants:

 Description   

We leave some perf on the table for this basic field lookup in a BSONObj. As this is fundamentally a parsing problem, we should only look at every byte once. However, we first scan the field name to determine its length (as part of constructing the BSONElement), and then we go back to compare the field name with the one we're looking for. If we start with comparing the field name, we avoid extra checks. 

This results in a speedup of up to 70% on the bson_bm array lookup test case.



 Comments   
Comment by Githook User [ 07/Feb/24 ]

Author:

{'name': 'Geert Bosch', 'email': 'GeertBosch@users.noreply.github.com', 'username': 'GeertBosch'}

Message: SERVER-86119 Speed up BSONObj::getField (#18656)

GitOrigin-RevId: 115aeaeeb03fbe876691172600b2db8246f22b95
Branch: master
https://github.com/mongodb/mongo/commit/ab617c1a9ac77d327a72fa9e266e57de9bb22e73

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