[SERVER-76917] Avoid redundant bounds check in field_ref Created: 08/May/23  Updated: 29/Oct/23  Resolved: 15/May/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0, 7.0.0-rc1

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

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Backport Requested:
v7.0
Participants:
Linked BF Score: 105

 Description   

FieldRef::getPart() gets called a lot; even moreso due to commit 851cfd2d . I observed that in https://github.com/10gen/mongo/blob/1c5aac135c035b7a7278a2dc49b44aa371e1cd1b/src/mongo/db/field_ref.cpp#L194-L197 we check the bounds on _parts, but _parts is a boost::container::small_vector which already does a bounds check in operator[](): https://github.com/10gen/mongo/blob/4973ef272c16f83e855c0d8ab5c9c2dc0d47d39f/src/third_party/boost/boost/container/vector.hpp#L1654

So we can remove that invariant check and save ~5%.



 Comments   
Comment by Githook User [ 12/May/23 ]

Author:

{'name': 'Colin Stolley', 'email': 'ccstolley@github.com', 'username': 'ccstolley'}

Message: SERVER-76917: Avoid redundant bounds check
Branch: v7.0
https://github.com/mongodb/mongo/commit/7992126f7852d313c549e322140b0a4808c92194

Comment by Githook User [ 08/May/23 ]

Author:

{'name': 'Colin Stolley', 'email': 'ccstolley@github.com', 'username': 'ccstolley'}

Message: SERVER-76917: Avoid redundant bounds check
Branch: master
https://github.com/mongodb/mongo/commit/4b505027e41823ae3dabeb56f8fe435c4baa8861

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