Avoid unnecessary string copies in NumberParser

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 7.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Service Arch
    • Fully Compatible
    • Service Arch 2023-10-02, Service Arch 2023-10-16
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      NumberParser is used in BSONElement, the SBE VM, and many _gen files. This class uses a helper function parseNumberFromStringHelper, where I see two unnecessary string copies: #1 and #2.

      In an extreme case I came up with, parsing one million numbers from {$match: {a: 1, b: 1, c: 1, ...}} originally took 4 seconds, and with a few lines change to avoid a copy it took 2 seconds instead, and the patch was green.

      We should also look at the Decimal128 constructors, they appear to make unnecessary copies as well.

            Assignee:
            Patrick Freed
            Reporter:
            Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: