[SERVER-68824] Coverity analysis defect 123333: Inefficient vector resizing with reserve. Created: 15/Aug/22  Updated: 05/Dec/22  Resolved: 17/Aug/22

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

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Backlog - Query Execution
Resolution: Won't Do Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Operating System: ALL
Participants:

 Description   

Inefficient vector resizing with reserve.

This operation, if performed to grow large vectors, may take a very long time to complete. A vector's capacity is increased with reserve in a manner that causes many unnecessary copies.
/src/mongo/db/pipeline/document_source_lookup.cpp:157: INEFFICIENT_RESERVE 123333 A "std::vector" has its capacity adjusted with "reserve()" in a manner that is likely to have severe performance penalties.



 Comments   
Comment by Kyle Suarez [ 17/Aug/22 ]

This call to std::vector::reserve() is not the inefficient variety because the final size is known a priori and so the memory reservation is done at most once.

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