Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving too many services at once causes performance degradation #249

Open
ospfranco opened this issue Mar 24, 2023 · 0 comments
Open

Comments

@ospfranco
Copy link

Thanks a lot for maintaining and developing the library.

We are using jMDNS in an embedded system where we are looking to onboard a large number of physical devices and we use mDNS to scan/detect those devices.

Everything worked fine in our testing until we started reaching a certain number of devices in the network (~50). At that point, we started noticing a large performance degradation. Device detection that might take some seconds would now take minutes, sometimes hours. Not everything can be attributed to jMDNS, we are running on an embedded system with tight resource constrains.

I have set up a simple test, from my machine I create 300 mDNS services via script:

#!/bin/bash

for i in {1..300} 
do 
  PORT=$(shuf -i 1024-65535 -n 1)
  dns-sd -R "OSP_$i" _abl-controller._tcp local $PORT hello=foo jakob=blah
done

Then I run jMDNS on my device and added some logs to the serviceResolved callback

@Override
public void serviceResolved(ServiceEvent event) {
    System.out.println("Service resolved: " + event.getInfo());
}

After a while, the resolve callback takes a very long time to be called and the device stops resolving services.

I had faced a similar issue on Android with another library, where resolving too many services at once caused a race condition. However, there seems to be no way to stop service resolution by jMDNS. I'm taking a look into the codebase myself but it is very complex and would require large modification (do not immediately trigger service resolution when a service is detected) but some guidance would be useful.

So far, I've only managed to kinda guess where the entry point of the listener/resolves lies but no idea where resolution takes place.

Any help is much appreciatted.

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

No branches or pull requests

1 participant