Performance of NetworkInterface methods on Windows

Daniel Fuchs daniel.fuchs at oracle.com
Tue Feb 7 20:51:33 UTC 2023


Hi Richard,

Welcome to OpenJDK :-)

A NetworkInterface object has a state, of which a subset
is a snapshot of some information that was read and copied
at the time the NetworkInterface object was created. Typically,
the list of addresses bound to the interface is a snapshot.

Getting the entire NetworkInterface all over again ensures that the
new interface object has a new refreshed snapshot of this
state. It may not be the best implementation
depending on what the calling code is trying to achieve, but
this is a long standing behavior (even though unspecified)
that cannot be changed without incurring high risk of regressions
in existing applications.

I'm not sure what your patch is proposing to do - but I'm not
sure it will be a pure performance fix without any impact on
observable behavior.

Naively caching interfaces created by a previous call would not work,
for instance.
There is certainly performance gains to be had, and making use of
the new foreign memory API to reduce the number of upcalls could
be an avenue to explore.
Backward compatibility is a concern to keep in mind though.

best regards,

-- daniel

PS: I see Alan has already replied on some other aspects
     of your inquiry.


On 07/02/2023 20:06, DiCroce, Richard wrote:
> Hi everyone,
> 
> I’d like to propose a patch to fix a performance issue with enumerating 
> network interfaces on Windows. The problem stems from the fact that 
> getAll calls createNetworkInterface for every interface, but does not 
> pass the list of interfaces that it has already collected. As a result, 
> createNetworkInterface gets the entire list all over again.
> 



More information about the net-dev mailing list