-
Notifications
You must be signed in to change notification settings - Fork 304
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
Bluez: improve get services performance #966
Conversation
This moves the D-Bus interface property dict types to the defs module. This will help avoid circular imports of the manager module.
This adds maps to improve performance when calling get_services(). Previously we had to enumerate all BlueZ D-Bus objects for each service, characteristic and descriptor. When there were many devices, this was a performance bottleneck. Instead, we can create a map of the D-Bus object tree as new interfaces appear, then use this map as an efficient way to find the child D-Bus object paths in the GATT tree. Fixes #927.
self._descriptor_map.setdefault( | ||
desc_props["Characteristic"], set() | ||
).add(obj_path) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could make the if
below an elif
This will definitely solve the performance issue. |
I did some testing with this and it seems the scanner is killed off when ever an active connection is being made. Not sure if its a regression on develop |
I double checking that on a different system, it could be a hardware issue |
Switched to a known good system and testing now |
Going to take a while to put batteries in enough bluetooth devices to get to the test level I had before |
connecting to a switchbot seems faster. digging though the callgrind now |
Connect time with services cached -- its a layered one top version (that overloads
|
Been testing with this in production and the performance improvement is noticeable |
This has been a really nice change. I added support for some switchbot lights in home-assistant/core#77430 and the performance improvement was quite noticeable on first connect |
Thanks for testing. |
Fixes #927.
See commit message for details.
@bdraco can you test and see if this actually makes a measurable difference in performance?