-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Networking
-
None
-
Networking & Observability
-
ALL
-
120
-
None
-
None
-
None
-
None
-
None
-
None
-
None
SessionWorkflow callsĀ _yieldPointReached() twice per request: in _getNextWork() before receiving the next request, and in _doOneIteration() right after sending the response. Each call ends in ServiceExecutor::yieldIfAppropriate(), which calls sched_yield() whenever more threads are running than there are cores. Nothing runs between the two points, so the second yield costs a syscall and a context switch without giving other threads a new chance to run. On a busy server sched_yield() was the most frequent syscall on the request path (about 2 per operation).
Keep one yield point per loop iteration, at the start of _getNextWork(), placed before the early return for an exhaust request that is already prepared, so that synthetic exhaust requests yield as well. This keeps the behaviour BF-27452 asked for (do not pin a CPU, let other threads run between requests) at one yield per request.
This removes the yield that SERVER-75109 restored, but not the way SERVER-73699 did: in 2023, removing it left exhaust responses and sessions without a dedicated thread with no yield at all. Now every iteration yields once, exhaust responses included, and the separate path for sessions without a dedicated thread no longer exists (SERVER-80766).
Measured effect
- YCSB workload B (95% read, 5% update): cycles/op -3.8%, instructions/op -2.4%, read latency average -4.2%, p95 -5.3%
- YCSB workload C (100% read): cycles/op -3.5%, instructions/op -2.2%, read latency average -1.6%
YCSB, single-node replica set, 5M documents in the WiredTiger cache; cycles and instructions per operation.
Risk
Scheduling only: the remaining yield happens at the same point of the loop as before; no protocol or data path change.
Tests
Adds the sessionWorkflowYieldPoint fail point at the yield point and two unit tests in session_workflow_test.cpp that count the yields: one per request, and one before each synthetic exhaust request.
- is related to
-
SERVER-75109 SessionWorkflow: restore the removed yield after send
-
- Closed
-
-
SERVER-73699 SessionWorkflow improvements
-
- Closed
-
-
SERVER-80766 Introduce ServiceExecutorInline
-
- Closed
-