Skip to content
  • Vincent Bernat's avatar
    net: ipv6: avoid overhead when no custom FIB rules are installed · feca7d8c
    Vincent Bernat authored
    If the user hasn't installed any custom rules, don't go through the
    whole FIB rules layer. This is pretty similar to f4530fa5 (ipv4:
    Avoid overhead when no custom FIB rules are installed).
    
    Using a micro-benchmark module [1], timing ip6_route_output() with
    get_cycles(), with 40,000 routes in the main routing table, before this
    patch:
    
        min=606 max=12911 count=627 average=1959 95th=4903 90th=3747 50th=1602 mad=821
        table=254 avgdepth=21.8 maxdepth=39
        value │                         ┊                            count
          600 │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒                                         199
          880 │▒▒▒░░░░░░░░░░░░░░░░                                      43
         1160 │▒▒▒░░░░░░░░░░░░░░░░░░░░                                  48
         1440 │▒▒▒░░░░░░░░░░░░░░░░░░░░░░░                               43
         1720 │▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░                          59
         2000 │▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░                      50
         2280 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░                    26
         2560 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░                  31
         2840 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░               28
         3120 │▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░              17
         3400 │▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░             17
         3680 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░             8
         3960 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░           11
         4240 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░            6
         4520 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░           6
         4800 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░           9
    
    After:
    
        min=544 max=11687 count=627 average=1776 95th=4546 90th=3585 50th=1227 mad=565
        table=254 avgdepth=21.8 maxdepth=39
        value │                         ┊                            count
          540 │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒                                        201
          800 │▒▒▒▒▒░░░░░░░░░░░░░░░░                                    63
         1060 │▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░                               68
         1320 │▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░                            39
         1580 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░                         32
         1840 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░                       32
         2100 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░                    34
         2360 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░                 33
         2620 │▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░               26
         2880 │▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░              22
         3140 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░              9
         3400 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░             8
         3660 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░             9
         3920 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░            8
         4180 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░           8
         4440 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░           8
    
    At the frequency of the host during the bench (~ 3.7 GHz), this is
    about a 100 ns difference on the median value.
    
    A next step would be to collapse local and main tables, as in
    0ddcf43d (ipv4: FIB Local/MAIN table collapse).
    
    [1]: https://github.com/vincentbernat/network-lab/blob/master/lab-routes-ipv6/kbench_mod.c
    
    
    
    Signed-off-by: default avatarVincent Bernat <vincent@bernat.im>
    Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
    Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    feca7d8c