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

Make CollectionShardingStateMap copy-on-write/otherwise lock-free

    • Type: Icon: Bug Bug
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Sharding
    • ALL

      The CollectionShardingState must be accessed on nearly every operation in a sharded cluster, which leads to a lot of contention on this mutex, as seen in a local perf run (though of course that's not a perfect representation). Because currently we never delete items from the map (it's append-only), and we only rarely add new items (on sharded collection creation), I think it would be a good candidate for a lock-free copy-on-write data structure, which would allow reads which do not create new entries to occur with only a few atomic reads rather than a full mutex acquisition. It would be pretty easy to try this and perf test it. At the very least, we could change the mutex to a ResourceMutex so that reads only require a SharedLock rather than an exclusive lock.

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            matthew.saltz@mongodb.com Matthew Saltz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: