-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Query Execution
-
None
-
Query Execution
-
Fully Compatible
-
QE 2026-08-03, QE 2026-08-17
-
200
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Updating a field in a wide document made mutable_bson Documents re- append every untouched field individually. Locating the target field materializes an `ElementRep` for each field to its left, and `writeChildren()` could only bulk-copy the still-opaque tail of the object, so that whole materialized prefix went through `BSONObjBuilder::append()` one element at a time.
Added `mutable_bson::Document::Impl::bulkCopyRightSiblings()`, which mirrors the existing tail copy. A maximal run of consecutive children whose bytes are still contiguous and unmodified in the parent's backing `BSONObj` is now appended with a single copy.
Modified, inserted, removed and renamed elements break the run, because `setValue()` repoints their rep at the leaf heap. Arrays are excluded, as their positional field names may need renumbering.
Added `SetFieldAtOffset` (apply only) and `SetFieldAtOffsetAndSerialize` (apply + serialize) microbenchmarks, sweeping fieldCount
{8, 512}× offset
{0, 50, 100}%. The offset sweep is what covers both paths: at 0% nothing is materialized to the left so serialization is almost entirely the old opaque-tail copy; at 100% the whole document is one run and the new copy does all the work. Baseline vs. patched, 7 repetitions (stddev <0.3%):
```
┌──────────────────────────┬─────────┬────────────┬────────┐
│ │ base ns │ patched ns │ delta │
├──────────────────────────┼─────────┼────────────┼────────┤
│ 512 / 100% │ 26739 │ 20841 │ −22.1% │
├──────────────────────────┼─────────┼────────────┼────────┤
│ 512 / 50% │ 14032 │ 11122 │ −20.7% │
├──────────────────────────┼─────────┼────────────┼────────┤
│ 8 / 100% │ 1286 │ 1208 │ −6.1% │
├──────────────────────────┼─────────┼────────────┼────────┤
│ 512 / 0% (old path only) │ 1195 │ 1203 │ +0.7% │
└──────────────────────────┴─────────┴────────────┴────────┘
```
The +0.7% regression is the run-length check failing immediately.
- related to
-
SERVER-32156 Linear field lookup in update subsystem can lead to an individual update having quadratic time complexity
-
- Needs Scheduling
-