IfState: Rust-based Acceleration¶
The upcoming ifstate 2.5 release will contain an optional rust-based acceleration for route and neighbor filtering. This can reduce processing time by more than 90% when using a routing daemon receiving the full table of the DFZ1.
About¶
IfState ignores kernel routes configured by routing daemons and dynamic neighbor table entries. It is not possible to filter these ignored routes or neighbors efficiently when querying the objects from the kernel via the netlink protocol. The full table has roughly about 250K IPv6 and 1M IPv4 prefixes resulting in about 1,25M preferred routes in the kernel RIB2. As those routes are learned dynamically IfState needs to ignore them while retrieving the routes from the kernel.
IfState needs a long time to process this huge number of routes received via the netlink protocol. IfState is implemented in Python and the single threaded decoding and filtering of this huge number of routes can take minutes, even on modern hardware. By migrating the route-filtering component from (C)Python to Rust, the processing time was reduced to just a few seconds.
libifstate-rs¶
libifstate-rs uses PyO3 to provide as Rust native Python package. The usage of libifstate-rs is optional and IfState will fallback to Python native route and neighbor filtering if the package is not available or has an incompatible version.
The libifstate-rs package is available at:
- PyPI
- IfState 2.5+ Debian packages
- Alpine Linux
- RouterKit RKOS
Benchmark¶
The following numbers are showing a small benchmark comparing the processing time for ifstate 2.4.2, ifstate 2.5.0-rc0 standalone and ifstate 2.5.0-rc0 with libifstate.
The tests were performed on an older spare hardware router (no forwarding load) with BGP3 full table executing the ifstatecli show command.
| ifstate 2.4.2 | ifstate 2.5.0-rc0 | ifstate 2.5.0-rc0 + libifstate-rs 0.4.0 | |||||||
| # | real | user | sys | real | user | sys | real | user | sys |
| 1 | 239.3 s | 234.1 s | 4.5 s | 168.0 s | 163.3 s | 4.1 s | 3.9 s | 2.9 s | 0.9 s |
| 2 | 240.9 s | 235.5 s | 4.7 s | 167.6 s | 163.1 s | 4.0 s | 3.9 s | 3.0 s | 0.9 s |
| 3 | 240.8 s | 235.5 s | 4.4 s | 161.5 s | 156.9 s | 4.2 s | 4.2 s | 2.9 s | 1.3 s |
| 4 | 240.4 s | 235.3 s | 4.4 s | 166.8 s | 162.3 s | 4.0 s | 3.8 s | 3.0 s | 0.8 s |
| 5 | 239.1 s | 234.1 s | 4.3 s | 168.0 s | 163.4 s | 4.2 s | 3.8 s | 2.9 s | 0.9 s |
| 6 | 239.4 s | 234.2 s | 4.4 s | 169.5 s | 164.5 s | 4.4 s | 4.9 s | 2.9 s | 2.0 s |
| 7 | 240.0 s | 234.4 s | 4.9 s | 167.8 s | 163.1 s | 4.2 s | 3.8 s | 2.9 s | 0.8 s |
| 8 | 239.3 s | 234.1 s | 4.6 s | 167.8 s | 163.2 s | 4.1 s | 4.5 s | 2.9 s | 1.6 s |
| 9 | 239.5 s | 234.4 s | 4.3 s | 168.4 s | 163.7 s | 4.2 s | 8.8 s | 3.0 s | 5.8 s |
| 10 | 237.6 s | 232.5 s | 4.4 s | 169.6 s | 164.8 s | 4.2 s | 4.4 s | 2.9 s | 1.4 s |
| Statistics | |||||||||
| AVG | 239.6 s | 234.4 s | 4.5 s | 167.5 s | 162.8 s | 4.1 s | 4.6 s | 2.9 s | 1.6 s |
| REL | 100 % | 100 % | 100 % | 70 % | 69 % | 92 % | 2 % | 1 % | 37 % |
| Test Bed | |||||||||
| CPU | Intel(R) Xeon(R) CPU E5-2667 v4 @ 3.20GHz | ||||||||
| Kernel | Linux 6.18.44 | ||||||||
| OS | Alpine Linux 3.24 | ||||||||
| Python | CPython 3.14.7 | ||||||||
| IPv6 | 249k routes | ||||||||
| IPv4 | 1,070k routes | ||||||||