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

feat: improve asyncio write performance #29

Merged
merged 21 commits into from
Sep 24, 2022
Merged

feat: improve asyncio write performance #29

merged 21 commits into from
Sep 24, 2022

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Sep 24, 2022

Similar to https://github.com/python/cpython/blob/2a50772b63d7bc4ef97d16e9bcc53455c301b0ea/Lib/asyncio/selector_events.py?rgh-link-date=2022-09-24T02%3A51%3A37Z#L914

With this change ~99% of writes don't need to be scheduled and can happen right away so it helps quite a bit with the latency

I was able to get sub 1s connection times on my yale locks with this change

2022-09-23 21:25:16.427 DEBUG (MainThread) [bleak_retry_connector] Family Room Door (M1028EZ) - /org/bluez/hci3/dev_78_9C_85_08_D2_CE: Connecting (attempt: 1, last rssi: -76)
2022-09-23 21:25:16.727 DEBUG (MainThread) [bleak_retry_connector] Family Room Door (M1028EZ) - /org/bluez/hci3/dev_78_9C_85_08_D2_CE: Connected (attempt: 1, last rssi: -76)

Previously the best I could do was slightly > 1s

fixes #28

@bdraco bdraco changed the title feat: improve write performance feat: improve asyncio write performance Sep 24, 2022
@codecov
Copy link

codecov bot commented Sep 24, 2022

Codecov Report

Base: 81.23% // Head: 81.01% // Decreases project coverage by -0.22% ⚠️

Coverage data is based on head (22f578f) compared to base (0bce72a).
Patch coverage: 80.00% of modified lines in pull request are covered.

❗ Current head 22f578f differs from pull request most recent head 04c12f7. Consider uploading reports for the commit 04c12f7 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #29      +/-   ##
==========================================
- Coverage   81.23%   81.01%   -0.23%     
==========================================
  Files          24       24              
  Lines        2840     2849       +9     
  Branches      619      623       +4     
==========================================
+ Hits         2307     2308       +1     
- Misses        327      330       +3     
- Partials      206      211       +5     
Impacted Files Coverage Δ
src/dbus_fast/message_bus.py 72.31% <50.00%> (-1.60%) ⬇️
src/dbus_fast/aio/message_bus.py 87.21% <90.90%> (-0.05%) ⬇️
src/dbus_fast/proxy_object.py 76.19% <0.00%> (-2.05%) ⬇️
src/dbus_fast/glib/message_bus.py 82.62% <0.00%> (+2.11%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bdraco
Copy link
Member Author

bdraco commented Sep 24, 2022

I don't think we can get rid of add_writer/remove_writer because its needed for unexpected disconnects.

However with this change ~99% of writes don't need to be scheduled and can happen right away so it helps quite a bit with the latency

@bdraco bdraco marked this pull request as ready for review September 24, 2022 07:44
@bdraco bdraco merged commit 016e71e into main Sep 24, 2022
@bdraco bdraco deleted the writer_asyncio branch September 24, 2022 07:47
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.

Writer is added and removed each request
1 participant