Skip to content

adjust active thread count adaptively#39

Open
sticnarf wants to merge 12 commits intotikv:masterfrom
sticnarf:adjust-active
Open

adjust active thread count adaptively#39
sticnarf wants to merge 12 commits intotikv:masterfrom
sticnarf:adjust-active

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 <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
@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 <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
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