Starting in 5.0.0, an aggregation pipeline that needs a JsExecution object always retrieves the JavaScript "scope" object every time this object is used in order to pass it to JsExecution::get() in case the JsExecution object has not already been created, as it is needed to create a JsExecution object. However, in sharded clusters this can result in making a new copy of the scope object for every document the query processes, and if the scope object is large this can add a significant overhead.
However, once the JsExecution object has been created for a given query thread, it gets cached for the lifetime of that thread, so the scope object is only needed once per thread. Thus there is no need to retrieve and potentially make another copy of the "scope" object if there is already a cached JsExecution object.
- is caused by
-
SERVER-47398 Stop using runtimeConstants, prefer 'let'.
- In Progress
- is related to
-
SERVER-91408 DocumentSourceLookUp::_fromExpCtx has unclear ownership
- Open