feat: speed up the query handler by bdraco · Pull Request #1350 · python-zeroconf/python-zeroconf

@bdraco

handle_assembled_query was still a bound method on the Zeroconf object. It can be moved to the query handler like we did for the record manager. This meant the listener had to jump back into the python stack for every answer packet when most of them will never be responded to.

@codecov

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b9aae1d) 99.75% compared to head (164eff5) 99.75%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1350   +/-   ##
=======================================
  Coverage   99.75%   99.75%           
=======================================
  Files          30       30           
  Lines        3240     3243    +3     
  Branches      536      536           
=======================================
+ Hits         3232     3235    +3     
  Misses          5        5           
  Partials        3        3           

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

@bdraco bdraco marked this pull request as ready for review

December 19, 2023 05:15

@bdraco bdraco deleted the handle_assembled_query branch

December 19, 2023 05:15

bdraco

Comment on lines +431 to +438

out_queue = self.zc.out_queue
out_queue.async_add(now, question_answers.mcast_aggregate)
if question_answers.mcast_aggregate_last_second:
# https://datatracker.ietf.org/doc/html/rfc6762#section-14
# If we broadcast it in the last second, we have to delay
# at least a second before we send it again
out_delay_queue = self.zc.out_delay_queue
out_delay_queue.async_add(now, question_answers.mcast_aggregate_last_second)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out_queue and out_delay_queue never change, we could rebind them to the QueryHandler object to avoid the getattr here but it probably doesn't make much difference as they should rarely be called in practice