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

Micro optimisations in wait_for_less_busy_worker feature #2579

Merged
merged 4 commits into from Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/puma/server.rb
Expand Up @@ -327,8 +327,7 @@ def handle_servers
break if handle_check
else
pool.wait_until_not_full
pool.wait_for_less_busy_worker(
@options[:wait_for_less_busy_worker].to_f)
pool.wait_for_less_busy_worker(@options[:wait_for_less_busy_worker])

io = begin
sock.accept_nonblock
Expand Down
3 changes: 2 additions & 1 deletion lib/puma/thread_pool.rb
Expand Up @@ -240,11 +240,12 @@ def wait_until_not_full

# @version 5.0.0
def wait_for_less_busy_worker(delay_s)
return unless delay_s && delay_s > 0

# Ruby MRI does GVL, this can result
# in processing contention when multiple threads
# (requests) are running concurrently
return unless Puma.mri?
return unless delay_s > 0

with_mutex do
return if @shutdown
Expand Down