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

Fastpath no-ops to multikey updates in IndexBuildInterceptor::sideWrite to avoid mutex acquisition

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.2.1, 4.3.1
    • Affects Version/s: None
    • Component/s: Storage
    • Labels:
      None
    • Fully Compatible
    • v4.2
    • Execution Team 2019-07-29, Execution Team 2019-09-09, Execution Team 2019-09-23

      The hybrid index build's IndexBuildInterceptor accumulates multikey changes in memory which is used to update the persisted index metadata once at the end of the index build.

      Every document inserted into the "side table" will grab a mutex to update this in-memory multikey paths variable. In the common case where a document is not multikey, this shared state does not need to be modified (multikey is similar to a set that can only be added to).

      The serialization was done out of convenience. There's only one exposed helper method for working with MultikeyPaths "objects". Specifically, the following two methods would allow only grabbing the mutex when a document is multikey w.r.t. an index:

      1. Instantiating the default/"empty" multikey object for a given index spec.
      2. A predicate that says whether a MultikeyPaths is equal to the default/"empty".

      Given (1), the _multikeyPaths can be initialized to the correct "shape" at IndexBuildInterceptor construction time. This clause can be removed.
      Given (2) merging would only need to happen if the document could potentially change multikey state.

      UPDATE: This optimization was only made for BTree indexes because all other index types either do not track path-level multikey information or have "special" handling of multikey paths.

            Assignee:
            maria.vankeulen@mongodb.com Maria van Keulen
            Reporter:
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: