Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust active thread count adaptively #39

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

sticnarf
Copy link
Contributor

@sticnarf sticnarf commented May 19, 2020

Edit: The self-adaptive strategy still needs some tuning. It's not so responsive in front of changing workloads

This PR adds another parking lot called backup. The threads parking in backup are much less often waked up. The workers except the backup ones are called active workers. The workers which are not parked are called running workers.

The working threads checks and records whether enough threads are utilized. If not enough threads are utilized continuously, a thread will be parked to the backup queue.

In contrast, if all threads are keeping utilized, it means we don't have enough working threads and we should unpark one from backup.

In this PR, the spawn method unparks threads only if the current running threads are less than min_thread_count. This reduces the latency in spawn side because unpark_one is a bit costy.
In most cases, ensure_workers is called by working threads when they pop a task from the queue.

sticnarf added 10 commits May 18, 2020 19:18
Signed-off-by: Yilin Chen <[email protected]>
Signed-off-by: Yilin Chen <[email protected]>
Signed-off-by: Yilin Chen <[email protected]>
Signed-off-by: Yilin Chen <[email protected]>
Signed-off-by: Yilin Chen <[email protected]>
Signed-off-by: Yilin Chen <[email protected]>
Signed-off-by: Yilin Chen <[email protected]>
Signed-off-by: Yilin Chen <[email protected]>
Signed-off-by: Yilin Chen <[email protected]>
@sticnarf sticnarf changed the title [WIP] adjust active thread count adaptively adjust active thread count adaptively May 19, 2020
@sticnarf sticnarf requested a review from BusyJay May 19, 2020 09:18
Signed-off-by: Yilin Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant