-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code, Write Ops
-
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.
- related to
-
SERVER-13521 Allow fast $push to front of an array
- Backlog