[SERVER-63858] IDL parser's 'any' serialisation type results in extra data copy Created: 19/Feb/22  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: Backlog - Service Architecture
Resolution: Unresolved Votes: 0
Labels: sa-remove-fv-backlog-22
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Service Arch
Participants:

 Description   

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.


Generated at Thu Feb 08 05:58:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.