feat: optimize construction of outgoing packets by bdraco · Pull Request #1118 · python-zeroconf/python-zeroconf

@bdraco

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

@bdraco

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

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

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

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

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