-
Type:
Task
-
Resolution: Declined
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Server Programmability
-
None
-
None
-
None
-
None
-
None
-
None
-
None
tl;dr eliminate unnecessary BSONElement construction inside BSONElementStorage/BSONColumn
For context, we have a couple of "High Value Workloads" we care about every time we measure performance. This is one of the workload regressions, and the aim is to mitigate this as much as we can.
My "BSONElement checks" PR makes BSONElement construction more expensive. It's very common that we perform more BSONElement constructions than we need to. BSONElement constructor used to be free (the element total size wasn't stored previously), so assumptions about BSONElement construction have changed. There are subsystems that construct BSONElement multiple times for the same element, for example BSONColumn or mutable_bson.
In this workload, we deal with BSONColumn. There is a particular code path where we perform BSONElement construction more than we need to
By the time BSONElementStorage::Element::element() is called, we already know the exact size of the element, but we re-do it here:
BSONElement BSONElementStorage::Element::element() const { // Include null byte and type byte in span. return {std::span<const char>(_buffer, _buffer + _nameSize + _valueSize + 2), _nameSize + 1, BSONElement::TrustedInitTag{}}; }
We have _nameSize and _valueSize already. I think the code change here would be to modify BSONElement to have a "TrustedSize" constructor.
- is related to
-
SERVER-136181 Investigate the performance of moving checks off of BSONElement constructor
-
- In Progress
-