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

Experiment with uvloop in the Gunicorn worker #6023

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGES/6021.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replaced async with uvloop as the Gunicorn worker eventloop.
7 changes: 6 additions & 1 deletion pulpcore/content/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class PulpcoreContentApplication(PulpcoreGunicornApplication):
def load_app_specific_config(self):
self.set_option("default_proc_name", "pulpcore-content", enforced=True)
self.set_option("worker_class", "aiohttp.GunicornWebWorker", enforced=True)
self.set_option("worker_class", "aiohttp.GunicornUVLoopWebWorker", enforced=True)

def load(self):
import pulpcore.content
Expand All @@ -15,6 +15,11 @@ def load(self):

@click.option("--bind", "-b", default="[::]:24816")
@click.option("--workers", "-w", type=int)
@click.option(
"--worker-class",
"-k",
type=click.Choice(["aiohttp.GunicornWebWorker", "aiohttp.GunicornUVLoopWebWorker"]),
)
# @click.option("--threads", "-w", type=int) # We don't use a threaded worker...
@click.option("--name", "-n", "proc_name")
@click.option("--timeout", "-t", type=int)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dependencies = [
"tablib<3.6.0",
"url-normalize>=1.4.3,<=1.4.3",
"uuid6>=2023.5.2,<=2024.7.10",
"uvloop>=0.21.0,<0.22",
Copy link
Member

Choose a reason for hiding this comment

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

Can we consider adding this as an optional dependency?

Copy link
Member Author

@pedro-psb pedro-psb Nov 21, 2024

Choose a reason for hiding this comment

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

Yes. Personally I would prefer to merge this as an optional feature.
Maybe do some discourse post to invite people to give it a try and provide feedback.
And make the default when we are comfortable with that.

Copy link
Member Author

Choose a reason for hiding this comment

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

@bmbouter Can we start with that? ^

Copy link
Member

Choose a reason for hiding this comment

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

Optional dependencies seem complicated. To me, the containers we build for the community would still have it installed because I don't think we want to ship options that then require users to rebuild containers. Pulp (imo) should Just Work™

At that point if it's optional in pulpcore, but still in 100% of the officially supported install method we'd do better just to keep it simple.

I'm fine with whatever you all decide.

Copy link
Member Author

Choose a reason for hiding this comment

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

My problem is not having strong evidence. I believe it will be fine (not break things) and improve performance, but I would like a bit more than that before shipping it widely. And also to justify to the build team why we are adding more deps.

I have a proposal which I prefer (over adding as optional and hoping someone will opt-in and provide feedback):

  1. We ship this as a patch on services for a fixed amount of time (1-3 months? on the agenda) with the purpose of gaining more trust (against breaks or regressions).
  2. We conduct some benchmarking (on services or not) and write a report. I would be happy to do/participate on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with all of that ^ FWIW.

Copy link
Member

Choose a reason for hiding this comment

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

I like this idea because it'll produce some real-world analysis. We can evaluate it first in the staging environment.

To do this we'll need the patch to be applied to this repo. Also have the usage of it enabled/disabled on the presence of an environment variable. If the env var is set use it, if the env var is non-existant don't. That will be the safest because then we can apply the patch and anywhere it goes it'll not break anything.

Then @dkliban or @decko can set the env var in the deployment repo (another repo with other contributors perms that are kind of hard to adjust). Also they can add uvloop to the container build file.

@pedro-psb could you open a patch like that? Feel free to message with us more about it, we'd like to help make it easy.

Copy link
Member

Choose a reason for hiding this comment

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

The containers are not the only way we ship pulp. That argument just does not work for me. OTOH more (hard) dependencies increase the possibility for random breakages by dependencies of dependencies interfering with each other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I can submit the patch.

"whitenoise>=5.0,<6.9.0",
"yarl>=1.8,<1.17.3",
]
Expand Down