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: optimize construction of outgoing packets #1118

Merged
merged 8 commits into from Dec 20, 2022
Merged

feat: optimize construction of outgoing packets #1118

merged 8 commits into from Dec 20, 2022

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Dec 20, 2022

This is ~27% speed up. We can get some more by optimizing the packing but the bulk of the run time is incoming so its likely not worth the maintenance burden to keep the pxd file in sync unless someone has a use case were they construct many outgoing packets.

@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2022

Codecov Report

Base: 99.72% // Head: 99.72% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (5cc30cf) compared to base (919d4d8).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1118   +/-   ##
=======================================
  Coverage   99.72%   99.72%           
=======================================
  Files          22       22           
  Lines        2561     2567    +6     
  Branches      452      454    +2     
=======================================
+ Hits         2554     2560    +6     
  Misses          5        5           
  Partials        2        2           
Impacted Files Coverage Δ
src/zeroconf/__init__.py 100.00% <100.00%> (ø)
src/zeroconf/_protocol/outgoing.py 100.00% <100.00%> (ø)

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 Dec 20, 2022

Screenshot 2022-12-19 at 9 28 37 PM

Screenshot 2022-12-19 at 9 28 29 PM

Screenshot 2022-12-19 at 9 28 16 PM

Remaining high hit branches

@bdraco
Copy link
Member Author

bdraco commented Dec 20, 2022

So the first is parsing the incoming message, its much smaller. Not much more we can do there

The rest is handling the question or responses.

Handle response is mostly cache lookups

@bdraco
Copy link
Member Author

bdraco commented Dec 20, 2022

Might make sense to do a pxd for the cache so we could make dns_entry_matches a cdef since it's called all over the place

@bdraco
Copy link
Member Author

bdraco commented Dec 20, 2022

Might not be worth the effort though as we already met the goal of cutting the base load cpu usage by 50% with this PR getting us over the mark

@bdraco
Copy link
Member Author

bdraco commented Dec 20, 2022

While the tests cover this 100%, I left it running overnight on 2 production systems to be sure there weren't any unexpected side effects and everything looks good this morning.

@bdraco bdraco marked this pull request as ready for review December 20, 2022 20:20
@bdraco bdraco merged commit 81e186d into master Dec 20, 2022
@bdraco bdraco deleted the outgoing branch December 20, 2022 20:20
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

2 participants