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

Benchmark and test changes to vector pre-filling in BSONIteratorSorted

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Service Arch
    • Fully Compatible
    • Service Arch 2024-04-01

      In a recent change to BSONIteratorSorted, we changed from using a raw array to a vector. In doing so, we pre-allocate the space for that vector, tapping into the nFields BSONObj function to get the number of fields. This function scans the BSONObj. We then, later, scan the BSONObj again to fill in the vector.

      It's possible to forgo a scan and not preallocate space in the vector. But it's a tradeoff. What has worse performance, scanning a BSONObj or constructing a vector item-by-item?

      We should benchmark this and see if it's worth changing.

      Also, we use .at() which is strictly worse performance than [] to access items.

      ivan.fefer@mongodb.com gets credit for finding this!

            Assignee:
            erin.mcnulty@mongodb.com Erin McNulty
            Reporter:
            blake.oler@mongodb.com Blake Oler
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: