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

Avoid future and scheduling overhead on sync command path

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • Service Arch

    Description

      Futures have a heavily optimized fast path for the case when they are already ready. It is intended to be essentially free in that case, while there is some unavoidable overhead in the case where it isn't yet ready at the time you chain additional work. This code is using a slower "not-ready-yet" path for futures, even though it triggers the chain before returning. Defuturizing or at least using makeReadyFutureWith() should be an easy win. Instead of doing this manually, consider just reverting this revert which reintroduced the suboptimal usage of futures here.

      This patch to SessionWorkflow::_scheduleNextIteration will bypass the scheduler overhead and keep running eager futures for sync networking:

      diff --git a/src/mongo/transport/session_workflow.cpp b/src/mongo/transport/session_workflow.cpp
      index 7342a707866..3ddc787deff 100644
      --- a/src/mongo/transport/session_workflow.cpp
      +++ b/src/mongo/transport/session_workflow.cpp
      @@ -809,7 +809,10 @@ void SessionWorkflow::Impl::_scheduleIteration() try {
               }
               if (useDedicatedThread()) {
                   try {
      -                _doOneIteration().get();
      +                while (useDedicatedThread()) {
      +                    _doOneIteration().get();
      +                    _work = nullptr;
      +                }
                       _scheduleIteration();
                   } catch (const DBException& ex) {
                       _onLoopError(ex.toStatus());
      

      Attachments

        Activity

          People

            backlog-server-servicearch Backlog - Service Architecture
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: