[SERVER-82832] Stop creating and destroying unnecessary vectors in checkAndAssertTypes Created: 06/Nov/23  Updated: 23/Nov/23  Resolved: 23/Nov/23

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

Type: Task Priority: Major - P3
Reporter: Vishnu Kaushik Assignee: Vishnu Kaushik
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screenshot 2023-11-06 at 1.25.17 PM.png     PNG File Screenshot 2023-11-06 at 1.27.25 PM.png    
Issue Links:
Related
Backwards Compatibility: Fully Compatible
Sprint: Repl 2023-11-13, Repl 2023-11-27
Participants:

 Description   

The IDL parser generator produces code of the form var.checkAndAssertTypes("Context", {BSONType1, BSONType2, ...}) , i.e. it produces code where a BSONType[] is passed to checkAndAssertTypes(). However, since this function expects a vector, the BSONType[] is repeatedly converted to a vector and then destroyed right after the function call.

Instead we can pass in pointers and make this a lot quicker to avoid many allocations and frees.

In the attached screenshots, the functions highlighted in purple represent amount of time spent doing this. The more elaborate screenshot is from a debug build, and there we see that the construction & destruction of vectors take about 40% of parse time. In the opt=on build, the construction & destruction take 20% of the total time



 Comments   
Comment by Githook User [ 22/Nov/23 ]

Author:

{'name': 'kauboy26', 'email': 'vishnu.kaushik@mongodb.com', 'username': 'kauboy26'}

Message: SERVER-82832 Stop creating and destroying vectors unnecessarily in checkAndAssertTypes
Branch: master
https://github.com/mongodb/mongo/commit/40c8c6eb881b0689932a3a849d8fb8ba73048e67

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