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

Avoid unnecessarily scanning chunks still not persisted during incremental refresh

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.0.6, 4.4.22, 5.0.18, 7.0.0-rc5
    • Component/s: None
    • None
    • Sharding EMEA

      On a shard, an incremental routing table refresh can start while there are still a lot of chunks that need to be persisted from a previous refresh. When this happens, almost the whole chunks vector is unnecessarily scanned in order to find the new entries.

      Example

      • 1M chunks already seen by previous refresh are being persisted
      • Refresh discovers 1 new chunk
      • 1M elements will be scanned here

      Solution
      Since collAndChunks.changedChunks is a sorted vector, we could simply invert the direction of the loop and scan in decreasing order starting from collAndChunks.changedChunks.end() . If we consider that it is very improbable for a lot of new chunks to be discovered, this will be even more efficient than performing a binary search on the vector.

            Assignee:
            backlog-server-sharding-emea [DO NOT USE] Backlog - Sharding EMEA
            Reporter:
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: