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

Implement support for bulk rightward copy of opaque regions when serializing mutable documents

    • Fully Compatible

      Currently, if a BSON Object in a mutable Document tree has had a change applied to one of its children, then the ElementRep for that Object is marked as deserialized.

      When we ask for a BSONObj representing the current state of the Document, the algorithm for serializing a de-serialized Object Element requires that we individually walk, represent, and then serialize each of its children.

      However, if we had never explored some rightward subregion of the Object (e.g. its right child pointer is opaque, and one of its realized children has an opaque right pointer), then that opaque region could be bulk copied, rather than walked. Doing a bulk copy would avoid the overhead of ElementRep creation for all of the demonstrably unaltered children.

      This would be particularly effective when updating "flat" documents like:

      { flat :

      { k_0 : a, k_1 : b, ... k_N : zz }

      }

      with updates like { $set :

      { flat.k_small : x }

      }

      since otherwise we would need to form ElementReps for all N Elements. Having support for bulk rightward copy would allow us to short circuit ElementRep construction once we had realized the ElementRep for flat.k_small.

        1. flat_update.js
          0.7 kB
          Andrew Morrow

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: