Avoid unnecessarily scanning chunks still not persisted during incremental refresh

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: 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
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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:
            [DO NOT USE] Backlog - Sharding EMEA
            Reporter:
            Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: