[SERVER-12578] Support in-place update of object/array elements when safe to do so Created: 03/Feb/14  Updated: 11/Jul/16  Resolved: 07/Apr/14

Status: Closed
Project: Core Server
Component/s: Internal Code, Write Ops
Affects Version/s: None
Fix Version/s: 2.7.0

Type: Improvement Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: Performance, mutable::document
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File inplace_object_rewrite.js    
Issue Links:
Related
Backwards Compatibility: Fully Compatible
Participants:

 Description   

We currently only support in-place element updates for primitive types. In-place updates for complex types is tricky, because even if the new object or array has the same size as the existing object, its internal layout may differ.

That means that any Element objects that referred to regions of memory in the original layout would be invalidated once the damage vector was applied. Currently, the semantics of Document is that Elements are never invalidated.

We could either:

  • State that you must abandon your Document after applying the damage vector to the supporting BSONObj, in which case we could simply enable support for in-place updates with object/array types right away, or:
  • Restrict applying in-place updates to object/array types to the case where the object or array to be updated in-place has opaque children, meaning that we had never formed any Element objects that referred into that region of memory, meaning that no Elements would be invalidated by the update.


 Comments   
Comment by Githook User [ 07/Apr/14 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@10gen.com'}

Message: SERVER-12578 Permit in-place mutation for all types when possible
Branch: master
https://github.com/mongodb/mongo/commit/d35fef6dddf7bf0c7b0837ea802bb6e9ab679a83

Comment by James Blackburn [ 25/Feb/14 ]

See also: SERVER-12886

This can be fixed by something like:
https://github.com/jamesblackburn/mongo/compare/SERVER-12886

which implements SERVER-66. Essentially it attempts to write back just dirty pages, which makes a big difference to small updates to larger documents.

Generated at Thu Feb 08 03:28:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.