Skip to content

Reduce string conversion in CaseInsensitiveDict lookups #173

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

Merged

Conversation

bdraco
Copy link
Contributor

@bdraco bdraco commented Aug 13, 2023

Use get_lower in a few more places and guard debug logging to avoid lookups when debug logging is not enabeld

@bdraco bdraco force-pushed the implement_get_CaseInsensitiveDict branch 4 times, most recently from 3095207 to a7628d3 Compare August 13, 2023 18:12
get was previously provided by the parent class which
had to raise KeyError for missing values. Since try/except
is only cheap for the non-exception case the performance
was not good when the key was missing

similar to python/cpython#106665
but in the HA case we call this even more frequently
@bdraco bdraco force-pushed the implement_get_CaseInsensitiveDict branch from a7628d3 to bdcca7b Compare August 13, 2023 18:18
@bdraco bdraco changed the title Implement get on CaseInsensitiveDict Reduce string conversion in CaseInsensitiveDict lookups Aug 13, 2023
@bdraco bdraco marked this pull request as ready for review August 13, 2023 19:18
@bdraco
Copy link
Contributor Author

bdraco commented Aug 13, 2023

Another thing we can do is skip doing a search if another host asked for a search within 50% of the time since the last search

If there are multiple HA hosts on the network they are all asking for searches which drives up the traffic a lot

@StevenLooman StevenLooman merged commit 93a9efa into StevenLooman:development Aug 13, 2023
@StevenLooman
Copy link
Owner

Thanks! Do you want a release with this?

@StevenLooman
Copy link
Owner

Another thing we can do is skip doing a search if another host asked for a search within 50% of the time since the last search

If there are multiple HA hosts on the network they are all asking for searches which drives up the traffic a lot

Sounds good to me. Should mostly be done in the ssdp component, with perhaps some changes in this library.

@bdraco bdraco deleted the implement_get_CaseInsensitiveDict branch August 13, 2023 20:08
@bdraco
Copy link
Contributor Author

bdraco commented Aug 13, 2023

No rush on a release. I only noticed it because a user had a LOT of sonos devices.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants