Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/pool/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ impl<T: TaskCell + Send> Local<T> {
if !self.core.mark_sleep() {
return false;
}
// If this thread is above core_thread_count, go to sleep
// without popping so scaled-down threads don't keep working.
if id > self.core.config.core_thread_count.load(Ordering::SeqCst) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the requirement that need to let the thread park immediately instead of trying to drain the tasks in the local queue? I think in most scenario, the difference should be very small.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the TiKV thread pool auto-scaling feature and observed that under load, TiKV scales down the number of threads — but the yatp pool does not shrink because its threads are occupied draining the queue and unified read pool CPU remains higher than the number of active threads shown by TiKV

return true;
}
task = self.local_queue.pop();
task.is_none()
},
Expand Down
Loading