keepsimple1 / mdns-sd

Rust library for mDNS based Service Discovery
Apache License 2.0
96 stars 37 forks source link

remove busy polling in the service daemon run loop #124

Closed keepsimple1 closed 1 year ago

keepsimple1 commented 1 year ago

https://github.com/keepsimple1/mdns-sd/blob/d0f7c2da89811bcbe094c70be496e382472fd8b1/src/service_daemon.rs#L296

Currently ServiceDaemon runs an event loop that uses a "busy polling" approach where it checks possible events at least every 20ms. This could be quite wasteful (CPU wise) if there is no much going on, and cause a possible delay of processing commands up to this timeout. Ideally we want to remove this "busy polling" and only checks everything when an event happens.

In other words, there are 2 benefits of removing busy polling the channel:

  1. Reduce CPU utilization.
  2. Reduce latency of reacting to incoming Commands.
keepsimple1 commented 1 year ago

done