-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Index resources in the UrlDispatcher to avoid linear search for most cases #7829
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #7829 +/- ##
=======================================
Coverage 97.41% 97.41%
=======================================
Files 107 107
Lines 32263 32347 +84
Branches 3750 3753 +3
=======================================
+ Hits 31428 31511 +83
Misses 632 632
- Partials 203 204 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
backport from aio-libs/aiohttp#7829
Backport to 3.10: 💚 backport PR created✅ Backport PR branch: Backported as #7917 🤖 @patchback |
…er to avoid linear search for most cases (#7917) **This is a backport of PR #7829 as merged into master (2a3eaa1).** --------- Co-authored-by: J. Nick Koston <[email protected]> Co-authored-by: Sam Bull <[email protected]>
…able is preceded by a fixed string after a slash (#8578) Co-authored-by: J. Nick Koston <[email protected]> fix for a regression in 3.10.x. Regressed in #7829 fixes #8567
…able is preceded by a fixed string after a slash (#8579) Co-authored-by: J. Nick Koston <[email protected]> fix for a regression in 3.10.x. Regressed in #7829 fixes #8567
What do these changes do?
The time complexity of the UrlDispatcher on a hit averaged
O(n)
The UrlDispatcher now keeps an index of all resources and will attempt to avoid doing a linear search to resolve. On a hit the performance should be nearly
O(url_parts)
on a miss the time complexity will beO(domains) + O(url_parts)
This works for prefixed subapps as well.
sub apps added by
add_domain
(akaMatchedSubAppResource
) will fallback to linear searching as they are not indexable since they support wildcard/regexsAre there changes in behavior for the user?
A fixed/static path will always be preferred over a dynamic path.
Related issue number
fixes #7828
benchmark
before (5002 urls)
before (7 urls)
after (5002 urls)
after (7 urls)
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.