Skip to content

IPRoute.link_lookup() is too slow #712

Open
@ffourcot

Description

@ffourcot

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions