[jitsi-dev] Performance improvement in UPNPHarvester


#1

Hi,
While profiling our application I noticed that quite a lot CPU time was spent in UPNPHarvester. More specifically it spent a lot of time in NetworkInterface.getNetworkInterfaces() while trying to discover the gateway. I therefore added a 5 minute cache of the GatewayDevice in UPNPHarvester (see attached patch). The code is not very beautiful but fairly straightforward. I am essentially caching the gateway in a static field and then have another field to determine whether the cache has timed out or not. The alternative would have been to add some library with more proper caching (e.g. Guava) but I didn't want to add an extra dependency just because of this small change.

We are creating lots of connections so this change is necessary for us to keep the CPU load within acceptable levels. I would love to have this patch accepted so we don't have to fork ice4j. Let me know if I can assist somehow or need to make some changes in order for you to accept it.

Regards
Carl

UPNPHarvester.java.patch (3.84 KB)