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

Improve performance of handling ports in the URL #1081

Merged
merged 9 commits into from
Sep 2, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Sep 2, 2024

What do these changes do?

There were a few places were the port got parsed out of the underlying SplitResult object multiple times. Make sure they are all cached to avoid doing the same work over and over.

This solves a minor performance regression that was introduced with the port normalization in #1033

Are there changes in behavior for the user?

performance improvement

Related issue number

#1033

For reference, is_default_port from update_headers in aiohttp is showing significantly higher on the profile with recent yarl versions.

before
is_default_port

after
update_headers_after

There were a few places were the port got parsed
out of the underlying SplitResult object multiple
times. Make sure they are all cached to avoid
doing the same work over and over.
Copy link

codecov bot commented Sep 2, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.02%. Comparing base (33ac3f1) to head (47b0d8f).
Report is 341 commits behind head on master.

Files with missing lines Patch % Lines
yarl/_url.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1081   +/-   ##
=======================================
  Coverage   93.01%   93.02%           
=======================================
  Files          31       31           
  Lines        4411     4414    +3     
  Branches      374      376    +2     
=======================================
+ Hits         4103     4106    +3     
  Misses        282      282           
  Partials       26       26           
Flag Coverage Δ
CI-GHA 92.97% <91.66%> (+<0.01%) ⬆️
MyPy 26.39% <41.66%> (+0.04%) ⬆️
OS-Linux 99.22% <100.00%> (+<0.01%) ⬆️
OS-Windows 99.44% <100.00%> (+<0.01%) ⬆️
OS-macOS 98.90% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 98.82% <100.00%> (+<0.01%) ⬆️
Py-3.10.14 99.07% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 99.07% <100.00%> (+<0.01%) ⬆️
Py-3.12.5 99.07% <100.00%> (+<0.01%) ⬆️
Py-3.13.0-rc.1 99.07% <100.00%> (+<0.01%) ⬆️
Py-3.8.10 98.76% <100.00%> (+<0.01%) ⬆️
Py-3.8.18 99.02% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 98.76% <100.00%> (+<0.01%) ⬆️
Py-3.9.19 99.02% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.11 99.19% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 99.22% <100.00%> (+<0.01%) ⬆️
VM-macos-latest 98.90% <100.00%> (+<0.01%) ⬆️
VM-ubuntu-latest 99.22% <100.00%> (+<0.01%) ⬆️
VM-windows-latest 99.44% <100.00%> (+<0.01%) ⬆️
pytest 99.22% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

yarl/_url.py Show resolved Hide resolved
yarl/_url.py Show resolved Hide resolved
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Sep 2, 2024
yarl/_url.py Outdated Show resolved Hide resolved
@bdraco
Copy link
Member Author

bdraco commented Sep 2, 2024

The line is covered that codecov/project/tests-pytest and codecov/patch is complaining about

.codecov.yml Outdated Show resolved Hide resolved
@bdraco bdraco marked this pull request as ready for review September 2, 2024 20:22
CHANGES/1081.misc.rst Outdated Show resolved Hide resolved
@bdraco bdraco merged commit f978d5e into master Sep 2, 2024
47 of 49 checks passed
@bdraco bdraco deleted the avoid_port_reparse_in_is_default_port branch September 2, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant