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 building unencoded URLs #1188

Merged
merged 13 commits into from
Oct 11, 2024
Merged

Improve performance of building unencoded URLs #1188

merged 13 commits into from
Oct 11, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Oct 11, 2024

What do these changes do?

Improve performance of building unencoded URLs

  • Move the host encoding out of _make_netloc so it can be cached (always requires an encoded host now -- internal change only)
  • Guard all _normalize_path with a "." check

Are there changes in behavior for the user?

no

baseline

Make URL with host and path and port: 0.111 sec
Make encoded URL with host and path and port: 0.024 sec
Make URL with host and path: 0.106 sec
Make URL with many hosts: 0.420 sec
Make URL with IPv4 Address and path and port: 0.113 sec
Make URL with IPv4 Address and path: 0.107 sec
Make URL with IPv6 Address and path and port: 0.128 sec
Make URL with IPv6 Address and path: 0.118 sec

this change

Make URL with host and path and port: 0.088 sec
Make encoded URL with host and path and port: 0.023 sec
Make URL with host and path: 0.086 sec
Make URL with many hosts: 0.410 sec
Make URL with IPv4 Address and path and port: 0.089 sec
Make URL with IPv4 Address and path: 0.093 sec
Make URL with IPv6 Address and path and port: 0.104 sec
Make URL with IPv6 Address and path: 0.105 sec

yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.59%. Comparing base (cf0ab10) to head (1ec78d9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1188      +/-   ##
==========================================
- Coverage   95.60%   95.59%   -0.01%     
==========================================
  Files          25       25              
  Lines        4887     4879       -8     
  Branches      260      262       +2     
==========================================
- Hits         4672     4664       -8     
  Misses        189      189              
  Partials       26       26              
Flag Coverage Δ
CI-GHA 95.57% <100.00%> (-0.01%) ⬇️
MyPy 42.43% <100.00%> (-0.12%) ⬇️
OS-Linux 99.38% <100.00%> (-0.03%) ⬇️
OS-Windows 99.45% <100.00%> (-0.03%) ⬇️
OS-macOS 99.07% <100.00%> (-0.03%) ⬇️
Py-3.10.11 98.97% <100.00%> (-0.03%) ⬇️
Py-3.10.15 99.25% <100.00%> (-0.03%) ⬇️
Py-3.11.10 99.25% <100.00%> (-0.03%) ⬇️
Py-3.11.9 98.97% <100.00%> (-0.03%) ⬇️
Py-3.12.7 99.25% <100.00%> (-0.03%) ⬇️
Py-3.13.0 99.25% <100.00%> (-0.03%) ⬇️
Py-3.8.10 98.92% <100.00%> (-0.03%) ⬇️
Py-3.8.18 99.20% <100.00%> (-0.03%) ⬇️
Py-3.9.13 98.92% <100.00%> (-0.03%) ⬇️
Py-3.9.20 99.20% <100.00%> (-0.03%) ⬇️
Py-pypy7.3.11 99.26% <100.00%> (-0.03%) ⬇️
Py-pypy7.3.16 99.26% <100.00%> (-0.03%) ⬇️
Py-pypy7.3.17 99.29% <100.00%> (-0.03%) ⬇️
VM-macos-latest 99.07% <100.00%> (-0.03%) ⬇️
VM-ubuntu-latest 99.38% <100.00%> (-0.03%) ⬇️
VM-windows-latest 99.45% <100.00%> (-0.03%) ⬇️
pytest 99.38% <100.00%> (-0.03%) ⬇️

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.

url_benchmark.py Outdated Show resolved Hide resolved
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 11, 2024
@bdraco bdraco marked this pull request as ready for review October 11, 2024 20:15
@bdraco bdraco merged commit 761debb into master Oct 11, 2024
47 of 49 checks passed
@bdraco bdraco deleted the unencoded_urls branch October 11, 2024 20:15
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