Skip to content

Defer decoding known answers until needed#983

Merged
bdraco merged 2 commits into
python-zeroconf:masterfrom
bdraco:lazy_decode_known_answers
Sep 16, 2021
Merged

Defer decoding known answers until needed#983
bdraco merged 2 commits into
python-zeroconf:masterfrom
bdraco:lazy_decode_known_answers

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented Sep 16, 2021

  • Right now we decode all known the answers in the packet even if we never need to look at them because we can't answer any of the questions in the packet

  • Decoding packets is the most expensive operation zeroconf performs on active networks. In fact it's the most expensive operation on a mostly idle home assistant instance.

  • Defer decoding to only when we need to check for suppression to save cpu time.

  • Closes Lazy decode known answers #980

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 16, 2021

Codecov Report

Merging #983 (eed76d9) into master (acf6457) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #983   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         2481      2493   +12     
  Branches       406       408    +2     
=========================================
+ Hits          2481      2493   +12     
Impacted Files Coverage Δ
zeroconf/_handlers.py 100.00% <ø> (ø)
zeroconf/_protocol.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update acf6457...eed76d9. Read the comment docs.

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented Sep 16, 2021

I wasn't expecting this much performance improvement, but event the 60s callgrind snapshot files are noticeably smaller.

Screen Shot 2021-09-16 at 11 34 09 AM

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented Sep 16, 2021

Screen Shot 2021-09-16 at 1 07 56 PM

Screen Shot 2021-09-16 at 1 07 34 PM

@bdraco bdraco marked this pull request as ready for review September 16, 2021 23:22
@bdraco bdraco merged commit 88b9875 into python-zeroconf:master Sep 16, 2021
@bdraco bdraco deleted the lazy_decode_known_answers branch September 16, 2021 23:23
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.

Lazy decode known answers

2 participants