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

Adds configuration option to set max_fast_inline #2406

Merged
merged 9 commits into from
Oct 19, 2020

Conversation

fdel15
Copy link
Contributor

@fdel15 fdel15 commented Oct 2, 2020

Description

Closes #2361

Adds a config option to set max_fast_inline and override the MAX_FAST_INLINE default. You can set this variable to Float::Infinity to address use cases that wish to maintain the pre version 3.12.2 behavior (as discussed in the issue).

Adds an ENV option to set MAX_FAST_INLINE constant. You can set this variable to zero to address use cases that wish to maintain the pre version 3.12.2 behavior (as discussed in the issue).

I didn't add any tests because it is not clear to me where to add them. This change affects the Puma::Server#process_client method, and it doesn't look like we have any tests set up at the moment. I also did not see any tests written when this change was introduced in the commits referenced in the issue v3.12.1...v3.12.2

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added an entry to History.md if this PR fixes a bug or adds a feature. If it doesn't need an entry to HISTORY.md, I have added [changelog skip] or [ci skip] to the pull request title.
  • I have added appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.

@nateberkopec nateberkopec added feature waiting-for-review Waiting on review from anyone labels Oct 2, 2020
History.md Outdated
@@ -9,6 +9,11 @@
* Refactor
* Consolidate option handling in Server, Server small refactors, doc chang (#2389)

## 5.0.3 / 2020-10-02
Copy link
Member

Choose a reason for hiding this comment

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

Please add any changelog entries to the "master" entry, above this one

lib/puma/const.rb Outdated Show resolved Hide resolved
lib/puma/server.rb Outdated Show resolved Hide resolved
@@ -124,7 +124,7 @@ module Const
# we amortize the cost of going back to the reactor for a well behaved
# but very "greedy" client across 10 requests. This prevents a not
# well behaved client from monopolizing the thread forever.
MAX_FAST_INLINE = 10
MAX_FAST_INLINE = ENV.fetch('MAX_FAST_INLINE', 10).to_i
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be cleaner to make this an attribute of the Server object, which is read from configuration.

We don't have any env variables setting constants right now, probably shouldn't start.

History.md Outdated
@@ -9,6 +9,11 @@
* Refactor
* Consolidate option handling in Server, Server small refactors, doc chang (#2389)

## 5.0.3 / 2020-10-02

* Features
Copy link
Member

Choose a reason for hiding this comment

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

Please add changelog entries to the "master" entry above this one

@nateberkopec nateberkopec added waiting-for-changes Waiting on changes from the requestor and removed waiting-for-review Waiting on review from anyone labels Oct 5, 2020
@nateberkopec
Copy link
Member

Cheers @fdel15! Thanks for your contribution!

Let's move this into the configuration object, like the other attributes on Server which get set as "options".

@fdel15
Copy link
Contributor Author

fdel15 commented Oct 10, 2020

Thanks for the feedback Nate. I should have time this weekend to make the requested changes.

@fdel15
Copy link
Contributor Author

fdel15 commented Oct 10, 2020

You can set this variable to zero to address use cases that wish to maintain the pre version 3.12.2 behavior

I originally had it working this way because an ENV variable is a string, so the INFINITY option that the issue suggested would not work. Since we are no longer using an ENV variable, we can allow users to set max_fast_inline to INFINITY to maintain the pre version 3.12.2 behavior.

@dentarg
Copy link
Member

dentarg commented Oct 11, 2020

@fdel15 can you update the title and PR description here to reflect what is actually happening now?

Could be discussed elsewhere, but I'll raise it now because the History.md diff here looks a bit funny. @nateberkopec @MSP-Greg should we remove the requirement that contributors update the changelog? now that @MSP-Greg has some tooling to do it

@dentarg
Copy link
Member

dentarg commented Oct 11, 2020

Also: I don't think CI should be skipped for this PR

@fdel15 fdel15 changed the title Adds ENV option to set MAX_FAST_INLINE [ci skip] Adds configuration option to set max_fast_inline Oct 11, 2020
@fdel15
Copy link
Contributor Author

fdel15 commented Oct 11, 2020

can you update the title and PR description here to reflect what is actually happening now?

Updated.

Also: I don't think CI should be skipped for this PR

I removed the CI skip. I added it because I didn't add any tests in the PR. I feel like now that I am doing more than just adding an ENV variable I should be adding tests, but I am not sure how to test this feature. Any guidance on this would be greatly appreciated.

@MSP-Greg
Copy link
Member

@fdel15

Thanks for the PR. This jumps around, so I won't inline it. In server.rb

attr_reader :max_fast_inline

and:

if requests >= max_fast_inline

One would normally prefer that the API only exposes methods and attributes that are required externally. max_fast_inline is currently not used anywhere other than the Server object, so it shouldn't have a reader. The conditional can just use the instance variable set in the initialize method.

Re History.md, you may need to rebase for that. Also, the code I've got for it only adds the link info. At present it doesn't add items to the log, as that would require exact tagging for what 'group' an entry is listed in.

@nateberkopec
Copy link
Member

Agree with @MSP-Greg's feedback that we want to keep the interface private.

@MSP-Greg
Copy link
Member

This needs to be added to puma/dsl.rb?

@fdel15
Copy link
Contributor Author

fdel15 commented Oct 18, 2020

One would normally prefer that the API only exposes methods and attributes that are required externally.

Feedback addressed. Good call about not exposing an internal attribute.

This needs to be added to puma/dsl.rb?

I think this is a good call as well. I added a max_fast_inline method and a test in test/config

@MSP-Greg
Copy link
Member

@fedl15

Do you see the message 'This branch cannot be rebased due to conflicts'? You may need to remove the commits in your PR branch that are duplicated, update your forks' master branch, then rebase on master in your PR branch. I think that made sense. I can help with more info if needed.

You'll notice all the files listed as changed above. It makes it hard to see what's changed when the master branch's commits are mixed in...

@fdel15 fdel15 force-pushed the max_fast_line_config_var-2361 branch from ff43f07 to cf7dc6a Compare October 18, 2020 02:05
@fdel15
Copy link
Contributor Author

fdel15 commented Oct 18, 2020

Do you see the message 'This branch cannot be rebased due to conflicts'?

I thought I fixed the conflicts when I rebased. I must've done something silly though that caused all the files to be listed as changed. Sorry for not catching that earlier. I cherry picked all my commits for the branch and force pushed them up. This should be good for review now.

History.md Show resolved Hide resolved
History.md Outdated Show resolved Hide resolved
@nateberkopec nateberkopec merged commit e8b9998 into puma:master Oct 19, 2020
@nateberkopec
Copy link
Member

Solid. Thanks for seeing this one through!

@nateberkopec
Copy link
Member

Whoops. I kinda forgot I wanted the next release to be a patchlevel. I may revert and then quickly re-revert this on Monday when we release.

nateberkopec added a commit that referenced this pull request Oct 25, 2020
nateberkopec added a commit that referenced this pull request Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature waiting-for-changes Waiting on changes from the requestor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: Make MAX_FAST_INLINE a configuration variable
4 participants