[SERVER-83715] Reserve vector size ahead of time when using DocumentSequences in generated IDL Parser Created: 29/Nov/23  Updated: 02/Jan/24  Resolved: 02/Jan/24

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: Billy Donahue
Resolution: Fixed Votes: 0
Labels: perf
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-83148 Investigate hand parsing bulkWrite co... Closed
Assigned Teams:
Service Arch
Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2024-01-08
Participants:

 Description   

When using DocumentSequences, we already know the size of the array to be deserialized ahead of time. This is because the DocumentSequence is stored as a std::vector within OpMsg. This is different from when the array is within the BSON body, in which case there is no way to know the size of the array without actually iterating through it.

The IDL parser generator can be changed here to include a values.reserve(sequence.objs.size()) call, so that when we are using DocumentSequences we don't have to perform vector reallocations due to not reserving the correct size ahead of time.

There may be additional scope for improvement here. Please investigate that as well

In bulkWrite perf investigations, this made a 10% difference.



 Comments   
Comment by Githook User [ 02/Jan/24 ]

Author:

{'name': 'Billy Donahue', 'email': 'BillyDonahue@users.noreply.github.com', 'username': 'BillyDonahue'}

Message: SERVER-83715 reserve document sequence vector (#17817)

GitOrigin-RevId: f0f89fb4670ae0bddd7f114825b8aa269fc25316
Branch: master
https://github.com/mongodb/mongo/commit/dd7b44a140d9ad3ce54ed9de9eecb637270471a0

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