Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-62980

Revert Perf Regression in BSON compareElementStringValues

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.3.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Execution Team 2022-02-07
    • 129

      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.

            Assignee:
            matt.kneiser@mongodb.com Matt Kneiser
            Reporter:
            matt.kneiser@mongodb.com Matt Kneiser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: