1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Micro optimisations in wait_for_less_busy_worker feature (#2579)

* Micro optimisations in `wait_for_less_busy_worker` feature

Two small things:

- https://github.com/puma/puma/pull/2079/files#r422738756 -> swap the order of calls so that the faster call (float comparison) runs first.
- https://github.com/puma/puma/pull/2079/files#r596114279 -> don't call `.to_f` on option that we already know is a float.

* Update server.rb

* Update thread_pool.rb

* Update thread_pool.rb
This commit is contained in:
Alex Ghiculescu 2021-03-17 14:11:38 -05:00 committed by GitHub
parent af94b78320
commit 78cf164e35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -327,8 +327,7 @@ module Puma
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

View file

@ -240,11 +240,12 @@ module Puma
# @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