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

Adds configuration option to set max_fast_inline (#2406)

* Adds ENV option to set MAX_FAST_INLINE

* Adds max_fast_inline as a configuration option to the server

* Updates changelong

* Adds Const:: prefix to MAX_FAST_INLINE

* Finally getting the hang of the changelog

* Removes attr_reader

* Adds max_fast_inline method to dsl

* Rubocop: Fixes Final newline missing

* Fixes History.md
This commit is contained in:
Frank DelPidio 2020-10-19 11:24:55 -04:00 committed by GitHub
parent c71d149117
commit e8b9998ba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 3 deletions

View file

@ -2,6 +2,7 @@
* Features
* Your feature goes here <Most recent on the top, like GitHub> (#Github Number)
* Adds max_fast_inline as a configuration option for the Server object (#2406)
* Bugfixes
* Cleanup daemonization in rc.d script (#2409)

View file

@ -198,7 +198,8 @@ module Puma
:logger => STDOUT,
:persistent_timeout => Const::PERSISTENT_TIMEOUT,
:first_data_timeout => Const::FIRST_DATA_TIMEOUT,
:raise_exception_on_sigterm => true
:raise_exception_on_sigterm => true,
:max_fast_inline => Const::MAX_FAST_INLINE
}
end

View file

@ -810,5 +810,12 @@ module Puma
def nakayoshi_fork(enabled=true)
@options[:nakayoshi_fork] = enabled
end
# The number of requests to attempt inline before sending a client back to
# the reactor to be subject to normal ordering.
#
def max_fast_inline(num_of_requests)
@options[:max_fast_inline] = Float(num_of_requests)
end
end
end

View file

@ -90,6 +90,7 @@ module Puma
@max_threads = options.fetch :max_threads , (Puma.mri? ? 5 : 16)
@persistent_timeout = options.fetch :persistent_timeout, PERSISTENT_TIMEOUT
@queue_requests = options.fetch :queue_requests, true
@max_fast_inline = options.fetch :max_fast_inline, MAX_FAST_INLINE
temp = !!(@options[:environment] =~ /\A(development|test)\z/)
@leak_stack_on_error = @options[:environment] ? temp : true
@ -441,11 +442,11 @@ module Puma
check_for_more_data = @status == :run
if requests >= MAX_FAST_INLINE
if requests >= @max_fast_inline
# This will mean that reset will only try to use the data it already
# has buffered and won't try to read more data. What this means is that
# every client, independent of their request speed, gets treated like a slow
# one once every MAX_FAST_INLINE requests.
# one once every max_fast_inline requests.
check_for_more_data = false
end

View file

@ -0,0 +1 @@
max_fast_inline Float::INFINITY

View file

@ -204,6 +204,14 @@ class TestConfigFile < TestConfigFileBase
assert_equal 150, conf.options[:worker_shutdown_timeout]
end
def test_config_files_with_float_convert
conf = Puma::Configuration.new(config_files: ['test/config/with_float_convert.rb']) do
end
conf.load
assert_equal Float::INFINITY, conf.options[:max_fast_inline]
end
def test_config_raise_exception_on_sigterm
conf = Puma::Configuration.new do |c|
c.raise_exception_on_sigterm false