Skip to content

Refactor frame helper to avoid py conversions when processing packets #641

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
merged 3 commits into from
Nov 16, 2023

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Nov 16, 2023

Since frame helper know about the APIConnection object now it can stay in native code the whole time to call the process_packet and report_fatal_error functions. Its a bit more tight coupling but frame helper is already tightly coupled to connection and its all internal anyways.

This makes processing incoming packets ~21% faster which is great for Bluetooth and log reader

The writer still does a lot of copying but thats mostly because of asyncio which is fixed in cpython 3.12
https://docs.python.org/3/whatsnew/3.12.html#asyncio

The performance of writing to sockets in asyncio has been significantly improved. asyncio now avoids unnecessary copying when writing to sockets and uses sendmsg() if the platform supports it. (Contributed by Kumar Aditya in gh-91166.)

@bdraco bdraco marked this pull request as draft November 16, 2023 18:05
Copy link

codecov bot commented Nov 16, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (d6293d9) 82.05% compared to head (392c971) 82.04%.
Report is 1 commits behind head on main.

Files Patch % Lines
aioesphomeapi/connection.py 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #641      +/-   ##
==========================================
- Coverage   82.05%   82.04%   -0.01%     
==========================================
  Files          14       14              
  Lines        2507     2506       -1     
==========================================
- Hits         2057     2056       -1     
  Misses        450      450              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco bdraco marked this pull request as ready for review November 16, 2023 18:19
@bdraco
Copy link
Member Author

bdraco commented Nov 16, 2023

missing coverage is existing (just a function rename)

@bdraco bdraco merged commit 3ccb36b into main Nov 16, 2023
@bdraco bdraco deleted the avoid_py_jump branch November 16, 2023 18:24
@bdraco
Copy link
Member Author

bdraco commented Nov 18, 2023

We are nearly at 84% coverage now 😁

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.

1 participant