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

Avoid unnecessary allocations when comparing TagSets in ReadPreferenceSetting

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Replication

      Creating a TagSet is expensive – every time we do it, we allocate an underlying BSONArray which in turn dynamically allocates a buffer.

      We are much too cavalier with creating TagSets. For example, we will create an empty TagSet for comparison here then immediately throw away the buffer we created. We will also create an empty TagSet to feed into creating a ReadPreferenceSetting and will potentially overwrite this with another TagSet buffer.

      I have a patch that avoids these allocations – this can be a good place to start. But we have potential here to cut down on what amounts to thousands of allocations in a ten minute workload.

        1. Screenshot 2024-03-25 at 1.24.44 PM.png
          72 kB
          Blake Oler
        2. Screenshot 2024-03-25 at 1.24.44 PM-1.png
          72 kB
          Blake Oler
        3. Screenshot 2024-03-25 at 1.22.53 PM.png
          399 kB
          Blake Oler

            Assignee:
            Unassigned Unassigned
            Reporter:
            blake.oler@mongodb.com Blake Oler
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: