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: speed up incoming packet reader #1314

Merged
merged 16 commits into from Nov 15, 2023
Merged

feat: speed up incoming packet reader #1314

merged 16 commits into from Nov 15, 2023

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Nov 13, 2023

This is ~14% speed up

before: Parsing 100000 incoming messages took 2.3616396670695394 seconds
after: Parsing 100000 incoming messages took 2.012439667014405 seconds

@bdraco bdraco changed the title feat: speed up outgoing packet writer feat: speed up incoming packet reader Nov 13, 2023
Copy link

codecov bot commented Nov 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (55cf4cc) 99.77% compared to head (872591a) 99.77%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1314   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files          29       29           
  Lines        3053     3079   +26     
  Branches      513      516    +3     
=======================================
+ Hits         3046     3072   +26     
  Misses          5        5           
  Partials        2        2           

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

@bdraco
Copy link
Member Author

bdraco commented Nov 13, 2023

The problem is its a 25% slow down for the pure python case

@bdraco bdraco closed this Nov 13, 2023
@bdraco bdraco reopened this Nov 14, 2023
@bdraco
Copy link
Member Author

bdraco commented Nov 14, 2023

I think this still has potential if we use an lru since 99% of the data is the same

Type, class can be one key

@bdraco
Copy link
Member Author

bdraco commented Nov 14, 2023

Maybe similar to how we do it in aioesphomeapi. Use a cache wrapper that cython can convert from memory view to bytes and than py int to uint

Should work because view is really bytes on pure python anyways.

But is it faster...?

@bdraco
Copy link
Member Author

bdraco commented Nov 14, 2023

At least in pure python we probably reduce gc cycles by 99%

@bdraco
Copy link
Member Author

bdraco commented Nov 14, 2023

Maybe it's better to keep the specialized unpacks but use the views instead.

@bdraco bdraco marked this pull request as ready for review November 15, 2023 05:41
@bdraco bdraco merged commit 0d60b61 into master Nov 15, 2023
34 checks passed
@bdraco bdraco deleted the refactor_packets branch November 15, 2023 05:41
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.

None yet

1 participant