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

Use aiohttp-fast-url-dispatcher to avoid linear searching to route urls #4705

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

balloob
Copy link
Member

@balloob balloob commented Nov 13, 2023

This is a non-fork version of #4683


The default UrlDispatcher implementation does a linear search every which can have a significant TimeComplexity when dispatching urls when there are a lot of routes. FastUrlDispatcher keeps an index of the urls which allows for fast dispatch.

This solution was original implemented in core as
https://github.com/home-assistant/core/blob/241e8560e99da4cbd3c9f763d77cfbd8badb1c66/homeassistant/components/http/__init__.py#L592

It is now in a PyPI package so it can be reused in other projects until aiohttp 3.10 which will solve the problem via aio-libs/aiohttp#7829

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to cli pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints of add-on configuration are added/changed:

@balloob balloob marked this pull request as draft November 13, 2023 22:36
@frenck
Copy link
Member

frenck commented Nov 13, 2023

This PR should not be merged until we have finished the current cycle.

@bdraco bdraco force-pushed the linear_search_urls branch from 7593d13 to 61c9472 Compare November 13, 2023 22:43
@bdraco bdraco added the performance A code change that improves performance label Nov 13, 2023
@frenck frenck force-pushed the linear_search_urls branch from 61c9472 to c9ce684 Compare November 13, 2023 22:44
@bdraco bdraco force-pushed the linear_search_urls branch from c9ce684 to 969de0b Compare November 13, 2023 22:45
@bdraco bdraco marked this pull request as ready for review November 16, 2023 17:09
@bdraco
Copy link
Member

bdraco commented Nov 16, 2023

I was holding on this because I thought there was a problem, but it was with an external addon and happens on main as well so it turned out to be a red herring

Copy link
Contributor

@mdegat01 mdegat01 left a comment

Choose a reason for hiding this comment

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

Not much to review but I see all the tests passed. Supervisor's API is pretty thoroughly unit tested at this point so this seems good to me then. Thanks @bdraco 👍

@mdegat01 mdegat01 merged commit 030527a into main Nov 16, 2023
22 checks passed
@mdegat01 mdegat01 deleted the linear_search_urls branch November 16, 2023 21:52
@bdraco
Copy link
Member

bdraco commented Nov 16, 2023

Thanks

@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed performance A code change that improves performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants