Open
Description
Hello,
link_lookup is mandatory for many use cases since we need interface index for almost all change/update.
However, current pyroute2 implementation is too slow. Especially in use case with many interfaces. On a computer with about thousands interfaces, we got:
In [19]: ipr = IPRoute()
In [20]: %timeit ipr.link_lookup(ifname="lo")
1 loop, best of 5: 294 ms per loop
When with another implementation:
In [22]: %timeit ipr.link("get", ifname="lo")[0]["index"]
1000 loops, best of 5: 491 µs per loop
In link_lookup, all filtering is done in userspace, since "dump" does not support kernel side filtering. With a simple "get" (kernel supports filtering on it), performance improvement is huge
Activity