[SERVER-55501] Avoid element-wise iteration and copy when appending to an object in doc_diff::applyDiff Created: 24/Mar/21  Updated: 29/Apr/21  Resolved: 29/Apr/21

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

Type: Task Priority: Major - P3
Reporter: Dan Larkin-York Assignee: Dan Larkin-York
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-56170 Investigate why some oplog entries ge... Closed
Issue split
split from SERVER-55350 Investigate single-threaded timeserie... Closed
Sprint: Execution Team 2021-04-19, Execution Team 2021-05-03
Participants:

 Description   

The current algorithm iterates over each field in the subdocument and copies it individually when adding a new field. In the timeseries case, where we may have hundreds of fields in each "column", this can be pretty bad quadratic behavior. The goal of this task is not to remove the quadratic behavior, but rather to minimize the coefficient for it by short-cutting: when we know we are just appending a field, we can take advantage of this to do a memcpy on the underlying BSON binary data, and just adjust the length for the subdocument to account for the new element.



 Comments   
Comment by Githook User [ 28/Apr/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-55501 Avoid element-wise iteration and copy when appending to an object in doc_diff::applyDiff
Branch: master
https://github.com/mongodb/mongo/commit/09e418805e9019cb56e54d240c7c7d9bcb95e339

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