-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Service Arch
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());
- duplicates
-
SERVER-81785 Avoid future and scheduling overhead on sync command path
- Closed