Improve ServiceExecutorSynchronous worker threads (SERVER-69905)

[SERVER-70145] reuse threads in ServiceExecutorSynchronous Created: 30/Sep/22  Updated: 29/Oct/23  Resolved: 30/Nov/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.3.0-rc0

Type: Sub-task Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2022-12-26, Service Arch 2022-10-17, Service Arch 2022-11-14, Service Arch 2022-11-28, Service Arch 2022-12-12, Service Arch 2023-01-09
Participants:

 Description   

From parent ticket SERVER-69905:

The biggest issue is that this executor makes a fresh thread for each toplevel task. The contract of this scheduler is that a toplevel task gets a dedicated thread, but it is not promising a FRESH brand new thread, only a dedicated one. So when the toplevel task completes, the worker thread should be reusable. But we don't reuse it. We let it exit and just make new threads for each connection. This seems extremely wasteful and we should just pool these workers and hand out leases to them. Essentially this is not so different from an ordinary ThreadPool except that the threads are different kinds of objects from the stdx::thread objects managed by ThreadPool.



 Comments   
Comment by Billy Donahue [ 30/Nov/22 ]

Done as part of SERVER-50171.

When a worker lease is released, we make a decision about whether to kill or reuse the worker. A very simple system was added to recycle worker threads if we aren't above a soft max number (initially picked to be # of cores).

Generated at Thu Feb 08 06:15:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.