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

Drop backing BSON in Document when possible



    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 4.3 Desired
    • Component/s: Querying
    • Labels:
    • Sprint:
      Query 2019-11-18, Query 2019-12-02, Query 2019-12-30


      Documents store a backing BSON object in addition to a cache of fields which have already been examined. This means they may be ~2x the size of the actual user document they represent. This makes copying them slower (we call getOwned() when crossing the find/agg membrane), and increases memory consumption. We should make an effort to drop this backing BSON when it is no longer necessary to hold onto.

      If this ticket gets scheduled, someone should think very hard about what conditions the backing BSON can be dropped are. I would start with the following:

      1) The backing BSON has been fully traversed (DocumentStorage::_bsonIt has reached the end)
      2) The metadata has been loaded from the backing BSON or the backing BSON has no metadata
      3) The original BSON will not be returned to the user. i.e. the Document has been modified, will be modified, or will be discarded. If this is the case then we'll never take the toBson() fast path which uses the original backing BSON.

      Point (3) is pretty broad, but for a first implementation we could only consider cases where the Document is already modified.




            • Votes:
              0 Vote for this issue
              5 Start watching this issue


              • Created: