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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Do
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Operating System:
      ALL

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            backlog-server-sharding Backlog - Sharding Team
            Reporter:
            matthew.saltz Matthew Saltz
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: