[SERVER-62980] Revert Perf Regression in BSON compareElementStringValues Created: 25/Jan/22  Updated: 29/Oct/23  Resolved: 26/Jan/22

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

Type: Bug Priority: Major - P3
Reporter: Matt Kneiser Assignee: Matt Kneiser
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2022-02-07
Participants:
Linked BF Score: 129

 Description   

SERVER-27209 introduced a large change taking BSONElement::valuestr() private as a means of deprecating its use outside of BSONElement.

Background

Since compareElementStringValues() is a bare function (i.e. external to BSONElement), I looked to simplify the logic when removing its use of the privatized valuestr(). That refactor introduced a low-level difference between how to compute the int return value of StringData::compare() vs. compareElementStringValues(). Basically boiling down to forcing one-ness in the return value of a string compare. This led to a ~10% perf regression in a sensitive test for a customer noted here: HELP-23789

Solution

I pasted the logic of BSONElement::valuestr() into compareElementStringValues(). While this may take a hit on readability, it achieves a simple replacement with no meaningful perf impact.



 Comments   
Comment by Matt Kneiser [ 26/Jan/22 ]

Fixes Hot BF: https://jira.mongodb.org/browse/BF-24070

Comment by Githook User [ 26/Jan/22 ]

Author:

{'name': 'Matt Kneiser', 'email': 'matt.kneiser@mongodb.com', 'username': 'themattman'}

Message: SERVER-62980 Revert simplification of compareElementStringValues for perf
Branch: master
https://github.com/mongodb/mongo/commit/c2ae46fba2647747b05fb95c84c9c0b4a5bffd5f

Generated at Thu Feb 08 05:56:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.