Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
2b1f39c
feat: significantly improve efficiency of the ServiceBrowser scheduler
bdraco Dec 14, 2023
d8a3a55
feat: significantly improve efficiency of the ServiceBrowser scheduler
bdraco Dec 14, 2023
ba6ee70
fix: py3.8 still supported
bdraco Dec 14, 2023
e4f5f20
fix: py3.8 still supported
bdraco Dec 14, 2023
26fbe21
fix: py3.8 still supported
bdraco Dec 14, 2023
675fdf7
fix: debug
bdraco Dec 14, 2023
2f79898
fix: time
bdraco Dec 14, 2023
6ecea13
fix: time
bdraco Dec 14, 2023
a758bcc
fix: slow memory leak
bdraco Dec 14, 2023
1a7c2f1
Merge branch 'master' into efficent_query_scheduler
bdraco Dec 14, 2023
430e678
fix: ensure all equality methods are implemented
bdraco Dec 14, 2023
2370685
fix: ensure all equality methods are implemented
bdraco Dec 14, 2023
946247a
fix: cleanup cancel method
bdraco Dec 14, 2023
43abc64
fix: cleanup cancel method
bdraco Dec 14, 2023
740c8c7
feat: split schedule methods
bdraco Dec 14, 2023
b028a6d
fix: typing error
bdraco Dec 14, 2023
eddf279
fix: always ask QU when populating the cache
bdraco Dec 14, 2023
fc62b4b
fix: tweaks
bdraco Dec 14, 2023
a695b05
fix: tweaks
bdraco Dec 14, 2023
150d146
fix: can be cancelled when we get a goodbye first
bdraco Dec 14, 2023
36550aa
fix: tweaks
bdraco Dec 14, 2023
644c4bb
fix: types
bdraco Dec 14, 2023
2382266
fix: types
bdraco Dec 14, 2023
b3aae50
fix: types
bdraco Dec 14, 2023
f33ab33
fix: types
bdraco Dec 14, 2023
4834742
fix: debug
bdraco Dec 14, 2023
cae5d4e
fix: reduce churn
bdraco Dec 14, 2023
a81c2e6
fix: reduce churn
bdraco Dec 14, 2023
3213a7f
fix: more efficient
bdraco Dec 14, 2023
20afec3
fix: account for clock resolution so we are not late
bdraco Dec 14, 2023
9799615
fix: const
bdraco Dec 14, 2023
a3f5b84
fix: tweak startup queries for bad wifi
bdraco Dec 14, 2023
04b1021
fixup
bdraco Dec 15, 2023
037d7d2
fix: cannot be patched or its late
bdraco Dec 15, 2023
6d31787
fix: adjust tests
bdraco Dec 15, 2023
5a789e2
chore: add time changed helper
bdraco Dec 15, 2023
31d1b66
fix: names and test
bdraco Dec 15, 2023
3b3fac0
fix: fixes
bdraco Dec 15, 2023
af8b8bc
fix: history
bdraco Dec 15, 2023
d7c8ecc
fix: rename to prevent errors
bdraco Dec 15, 2023
846a6e7
fix: refactor test
bdraco Dec 15, 2023
e054a98
fix: move guards
bdraco Dec 15, 2023
af1a232
fix: move guards
bdraco Dec 15, 2023
43716e6
fix: remove dead code
bdraco Dec 15, 2023
d904d10
fix: legacy
bdraco Dec 15, 2023
dc93855
fix: legacy
bdraco Dec 15, 2023
e89f64e
fix: break ref cycles on stop
bdraco Dec 15, 2023
c69b890
fix: debug
bdraco Dec 15, 2023
605f0f8
fix: names
bdraco Dec 15, 2023
9f8a2f1
fix: handle devices that ignore QU
bdraco Dec 15, 2023
59adfbc
fix: revert QU change
bdraco Dec 15, 2023
8037ced
fix: remove debug
bdraco Dec 15, 2023
79a4283
Merge branch 'master' into efficent_query_scheduler
bdraco Dec 15, 2023
e3e4090
Merge branch 'master' into efficent_query_scheduler
bdraco Dec 15, 2023
817506b
Merge branch 'master' into efficent_query_scheduler
bdraco Dec 15, 2023
c9262a5
feat: retry queries until ttl reached
bdraco Dec 15, 2023
4588f01
feat: retry queries until ttl reached
bdraco Dec 15, 2023
3910b0d
feat: retry queries until ttl reached
bdraco Dec 15, 2023
6cda0de
Merge branch 'master' into efficent_query_scheduler
bdraco Dec 15, 2023
615bc8b
chore: comments
bdraco Dec 15, 2023
38bb278
fix: tweak
bdraco Dec 15, 2023
e978d6c
fix: cleanup
bdraco Dec 15, 2023
0082e41
fix: tweaks
bdraco Dec 15, 2023
d1f7e08
fix: fixes
bdraco Dec 15, 2023
626ef58
fix: remove unused code
bdraco Dec 15, 2023
ccb53bf
fix: remove unused code
bdraco Dec 15, 2023
45bf381
fix: drop call if unused
bdraco Dec 15, 2023
024906a
fix: naming
bdraco Dec 15, 2023
18021ee
chore: add units for _ScheduledPTRQuery dunder methods
bdraco Dec 15, 2023
3c39ec6
fix: tests
bdraco Dec 15, 2023
a62901f
fix: tests
bdraco Dec 15, 2023
e2d39da
feat: add stop sending tests
bdraco Dec 15, 2023
3bb26ff
fix: we need the ttl
bdraco Dec 15, 2023
8686dea
chore: update comments
bdraco Dec 15, 2023
822a009
fix: consistant naming
bdraco Dec 15, 2023
7208da6
chore: move async_send_ready_queries out of the browser itself
bdraco Dec 15, 2023
30259f2
fix: remove object vars that are moved to the query scheduler
bdraco Dec 15, 2023
3b7e0d5
fix: remove object vars that are moved to the query scheduler
bdraco Dec 15, 2023
be0fe64
fix: cythonize
bdraco Dec 15, 2023
ff1d9db
Merge branch 'master' into efficent_query_scheduler
bdraco Dec 16, 2023
8bb7486
chore: add more types
bdraco Dec 16, 2023
ae0665f
fix: tests
bdraco Dec 16, 2023
d65e1e4
chore: fix comments
bdraco Dec 16, 2023
81073ed
chore: fix tests
bdraco Dec 16, 2023
425de23
chore: unit tests for query scheduler
bdraco Dec 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def on_service_state_change(

zeroconf = Zeroconf(ip_version=ip_version)

services = ["_http._tcp.local.", "_hap._tcp.local."]
services = ["_http._tcp.local.", "_hap._tcp.local.", "_esphomelib._tcp.local.", "_airplay._tcp.local."]
if args.find:
services = list(ZeroconfServiceTypes.find(zc=zeroconf))

Expand Down
87 changes: 57 additions & 30 deletions src/zeroconf/_services/browser.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -14,79 +14,106 @@ cdef bint TYPE_CHECKING
cdef object cached_possible_types
cdef cython.uint _EXPIRE_REFRESH_TIME_PERCENT, _MAX_MSG_TYPICAL, _DNS_PACKET_HEADER_LEN
cdef cython.uint _TYPE_PTR
cdef object _CLASS_IN
cdef object SERVICE_STATE_CHANGE_ADDED, SERVICE_STATE_CHANGE_REMOVED, SERVICE_STATE_CHANGE_UPDATED
cdef cython.set _ADDRESS_RECORD_TYPES
cdef float RESCUE_RECORD_RETRY_TTL_PERCENTAGE

cdef object _MDNS_PORT, _BROWSER_TIME

cdef object QU_QUESTION

cdef object _FLAGS_QR_QUERY

cdef object heappop, heappush

cdef class _ScheduledPTRQuery:

cdef public str alias
cdef public str name
cdef public unsigned int ttl
cdef public bint cancelled
cdef public double expire_time_millis
cdef public double when_millis

cdef class _DNSPointerOutgoingBucket:

cdef public object now
cdef public double now_millis
cdef public DNSOutgoing out
cdef public cython.uint bytes

cpdef add(self, cython.uint max_compressed_size, DNSQuestion question, cython.set answers)

@cython.locals(cache=DNSCache, question_history=QuestionHistory, record=DNSRecord, qu_question=bint)
cpdef generate_service_query(
cpdef list generate_service_query(
object zc,
double now,
list type_,
double now_millis,
set types_,
bint multicast,
object question_type
)

@cython.locals(answer=DNSPointer, query_buckets=list, question=DNSQuestion, max_compressed_size=cython.uint, max_bucket_size=cython.uint, query_bucket=_DNSPointerOutgoingBucket)
cdef _group_ptr_queries_with_known_answers(object now, object multicast, cython.dict question_with_known_answers)
cdef list _group_ptr_queries_with_known_answers(double now_millis, bint multicast, cython.dict question_with_known_answers)

cdef class QueryScheduler:

cdef cython.set _types
cdef cython.dict _next_time
cdef object _first_random_delay_interval
cdef cython.dict _delay
cdef object _zc
cdef set _types
cdef str _addr
cdef int _port
cdef bint _multicast
cdef tuple _first_random_delay_interval
cdef double _min_time_between_queries_millis
cdef object _loop
cdef unsigned int _startup_queries_sent
cdef public dict _next_scheduled_for_alias
cdef public list _query_heap
cdef object _next_run
cdef double _clock_resolution_millis
cdef object _question_type

cpdef void schedule_ptr_first_refresh(self, DNSPointer pointer)

cdef void _schedule_ptr_refresh(self, DNSPointer pointer, double expire_time_millis, double refresh_time_millis)

cdef void _schedule_ptr_query(self, _ScheduledPTRQuery scheduled_query)

cpdef millis_to_wait(self, object now)
@cython.locals(scheduled=_ScheduledPTRQuery)
cpdef void cancel_ptr_refresh(self, DNSPointer pointer)

cpdef reschedule_type(self, object type_, object next_time)
@cython.locals(current=_ScheduledPTRQuery, expire_time=double)
cpdef void reschedule_ptr_first_refresh(self, DNSPointer pointer)

cpdef process_ready_types(self, object now)
@cython.locals(ttl_millis='unsigned int', additional_wait=double, next_query_time=double)
cpdef void schedule_rescue_query(self, _ScheduledPTRQuery query, double now_millis, float additional_percentage)

cpdef void _process_startup_queries(self)

@cython.locals(query=_ScheduledPTRQuery, next_scheduled=_ScheduledPTRQuery, next_when=double)
cpdef void _process_ready_types(self)

cpdef void async_send_ready_queries(self, bint first_request, double now_millis, set ready_types)

cdef class _ServiceBrowserBase(RecordUpdateListener):

cdef public cython.set types
cdef public object zc
cdef DNSCache _cache
cdef object _loop
cdef public object addr
cdef public object port
cdef public object multicast
cdef public object question_type
cdef public cython.dict _pending_handlers
cdef public object _service_state_changed
cdef public QueryScheduler query_scheduler
cdef public bint done
cdef public object _first_request
cdef public object _next_send_timer
cdef public object _query_sender_task

cpdef _generate_ready_queries(self, object first_request, object now)

cpdef void _enqueue_callback(self, object state_change, object type_, object name)

@cython.locals(record_update=RecordUpdate, record=DNSRecord, cache=DNSCache, service=DNSRecord, pointer=DNSPointer)
cpdef void async_update_records(self, object zc, double now, cython.list records)

cpdef cython.list _names_matching_types(self, object types)

cpdef reschedule_type(self, object type_, object now, object next_time)

cpdef _fire_service_state_changed_event(self, cython.tuple event)

cpdef _async_send_ready_queries_schedule_next(self)

cpdef _async_schedule_next(self, object now)

cpdef _async_send_ready_queries(self, object now)

cpdef _cancel_send_timer(self)

cpdef void async_update_records_complete(self)
Loading