-
Type:
Improvement
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
Currently, getOwned() is called on a BSONObj constructed from a temporary buffer, and makes a copy.
However, that temporary buffer is later released as the buffer underlying dbResponse.response.
It is not necessary to copy the data, if we can instead share ownership with response.
Example diff: response_body.diff
This will need testing, but should be reasonably easy to validate. Note that it does depend on internal behaviour of BSONObjBuilder / ReplyBuilderInterface, expecting that asTempObj() followed by done() does not lead to a re-allocation of the underlying buffer.
An alternative would be simply to note the correct offset into the buffer at which the body is being written (effectively finding the same value present in OpMsgBuilder::_bodyStart, but it can be derived with pointer arithmetic from distance from the buffer start, to the start of the data in asTempObj()).
A less ideal third option would be to simply parse the response far enough to find Section::kBody with BufReader.
- duplicates
-
SERVER-99151 Avoid unnecessary copying of response data
-
- Open
-