Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-91362

Performance: Do not copy JS "scope" object if a cached JsExecution exists

    • Query Execution
    • Fully Compatible
    • ALL
    • v8.0, v7.3, v7.0, v6.0, v5.0

      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.

        1. help58993Try06.02_db.runCommand_form.js
          27 kB
        2. Help58993Try06.yml
          3 kB
        3. setup.2_shards.psa_repl
          7 kB

            Assignee:
            kevin.cherkauer@mongodb.com Kevin Cherkauer
            Reporter:
            kevin.cherkauer@mongodb.com Kevin Cherkauer
            Votes:
            0 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: