Skip to content

feat: optimize construction of outgoing packets#1118

Merged
bdraco merged 8 commits into
masterfrom
outgoing
Dec 20, 2022
Merged

feat: optimize construction of outgoing packets#1118
bdraco merged 8 commits into
masterfrom
outgoing

Conversation

@bdraco

@bdraco bdraco commented Dec 20, 2022

Copy link
Copy Markdown
Member

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

codecov-commenter commented Dec 20, 2022

Copy link
Copy Markdown

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

bdraco commented Dec 20, 2022

Copy link
Copy Markdown
Member Author

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

bdraco commented Dec 20, 2022

Copy link
Copy Markdown
Member Author

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

bdraco commented Dec 20, 2022

Copy link
Copy Markdown
Member Author

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

bdraco commented Dec 20, 2022

Copy link
Copy Markdown
Member Author

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

bdraco commented Dec 20, 2022

Copy link
Copy Markdown
Member Author

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.

2 participants