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

IDL parser's 'any' serialisation type results in extra data copy

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability

      The code that is generated when one specifies a type with serialisation type of 'any' looks like this:

              BSONArrayBuilder arrayBuilder(builder->subarrayStart(kWriteErrorsFieldName));
              for (const auto& item : _writeErrors.get()) {
                  const BSONObj localObject = item.serialize();
                  arrayBuilder.append(localObject);
              }
      

      This means that the serialiser method returns a free-standing BSONObject, which is then copied into the main builder.

      It would be more efficient if the serialiser generated looked like this in order to avoid the data copy:

              BSONArrayBuilder arrayBuilder(builder->subarrayStart(kWriteErrorsFieldName));
              for (const auto& item : _writeErrors.get()) {
                  item.serialize(arrayBuilder.subObjectStart(localObject));
              }
      

      This would require all places that use serialisation type of any currently to be changed so that their serialise method takes a BSONObjBuilder instead of returning BSONObj.

            Assignee:
            Unassigned Unassigned
            Reporter:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: