The DiscoveryBooster.take_step() method intermittently exhibits slow performance, sometimes taking several seconds to execute a single call, blocking the asyncio loop. This method internally invokes EdgeWalk.take_step(), where EdgeWalk is instantiated with the parameters neighborhood_size=25, edge_length=25.
I profiled the slow EdgeWalk.take_step() execution and discovered that the bulk of the execution time was consumed by calls to netifaces.ifaddresses and netifaces.interfaces. Here are the statistics derived from profiling:
As seen, the total execution time for EdgeWalk.take_step() was 2.015 seconds. Of this, 1.577 seconds were spent in netifaces.ifaddresses and 0.380 seconds in netifaces.interfaces.
Even though each individual invocation of netifaces.ifaddresses or netifaces.interfaces was reasonably fast (0.003 seconds per call), the sheer quantity of these calls (580 calls to netifaces.ifaddresses and 145 to netifaces.interfaces) resulted in a significant accumulation of execution time.
Proposed Mitigation:
To enhance the performance of the take_step method, we can cache the results from netifaces.ifaddresses and netifaces.interfaces. The cache duration could be a few seconds, which should significantly boost the speed of the take_step calls while still maintaining network information accuracy.
The
DiscoveryBooster.take_step()
method intermittently exhibits slow performance, sometimes taking several seconds to execute a single call, blocking the asyncio loop. This method internally invokesEdgeWalk.take_step()
, whereEdgeWalk
is instantiated with the parametersneighborhood_size=25, edge_length=25
.I profiled the slow
EdgeWalk.take_step()
execution and discovered that the bulk of the execution time was consumed by calls tonetifaces.ifaddresses
andnetifaces.interfaces
. Here are the statistics derived from profiling:As seen, the total execution time for
EdgeWalk.take_step()
was 2.015 seconds. Of this, 1.577 seconds were spent innetifaces.ifaddresses
and 0.380 seconds innetifaces.interfaces
.Even though each individual invocation of
netifaces.ifaddresses
ornetifaces.interfaces
was reasonably fast (0.003 seconds per call), the sheer quantity of these calls (580 calls tonetifaces.ifaddresses
and 145 tonetifaces.interfaces
) resulted in a significant accumulation of execution time.Proposed Mitigation:
To enhance the performance of the
take_step
method, we can cache the results fromnetifaces.ifaddresses
andnetifaces.interfaces
. The cache duration could be a few seconds, which should significantly boost the speed of thetake_step
calls while still maintaining network information accuracy.