Skip to contentSkip to conversation

(diet-)FIB alternative fib_hlist.c

PATCH Robert Olsson 4 participants 7 messages May 4, 2005 – May 6, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello!

fib_hlist is the smallest and simpliest routing algo we could think of it's just a sorted (h)list.

routing (FIB lookup) performance. dst hash is not used.

    fib_hlist   fib_hash  test        routing table size 
    -----------------------------------------------------
    444 kpps    433 kpps  Single flow. local=19/main=5 entries
    433 kpps    431 kpps  rDoS.        local=19/main=5
    0.2 kpps    198 kpps  rDoS         local=19/main=123946

As seen fib_hlist is catastrophe for large routing tables as expected but performs surprisingly well for ordinary routing tables so it should be fine for most hosts and servers. The patch has config option to select FIB.

Probably we soon want to specify differnt lookup schemes for different tables say for local table fib_hash or fib_hlist. While for large main table fib_hash2/fib_trie would be better option.

Cheers.

					--ro
ipv4/Makefile renamed from ipv4/Makefile.orig +3 -1
@@ -7,8 +7,10 @@
 	     ip_output.o ip_sockglue.o \
 	     tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o tcp_minisocks.o \
 	     datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \
-	     sysctl_net_ipv4.o fib_frontend.o fib_semantics.o fib_hash.o
+	     sysctl_net_ipv4.o fib_frontend.o fib_semantics.o
 
+obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o
+obj-$(CONFIG_IP_FIB_HLIST) += fib_hlist.o
 obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o
 obj-$(CONFIG_IP_MROUTE) += ipmr.o
ipv4/Kconfig renamed from ipv4/Kconfig.orig +21 -0
@@ -1,6 +1,27 @@
 #
 # IP configuration
 #
+choice 
+	prompt "Choose IP: FIB lookup""
+	depends on INET
+	default IP_FIB_HASH
+
+config IP_FIB_HASH
+	bool "FIB_HASH"
+	---help---
+	Current FIB is very proven and good enough for most users.
+
+config IP_FIB_HLIST
+	bool "FIB_HLIST"
+	depends on INET && EXPERIMENTAL	
+	---help---
+
+	Use new very simple and minimalistic lookup algorithm. It should
+	only be used for small routing tables. Performance is equal to
+	FIB_HASH with small tables but with less memory use.
+
+endchoice
+
 config IP_MULTICAST
 	bool "IP: multicasting"
 	depends on INET
ipv4/fib_hlist.c new file +719 -0

719 lines not on this page · raw message

#1 lore raw
Quoted 13 lines · Robert Olsson

Hello!

fib_hlist is the smallest and simpliest routing algo we could think of it's just a sorted (h)list.

routing (FIB lookup) performance. dst hash is not used.

    fib_hlist   fib_hash  test        routing table size 
    -----------------------------------------------------
    444 kpps    433 kpps  Single flow. local=19/main=5 entries
    433 kpps    431 kpps  rDoS.        local=19/main=5
    0.2 kpps    198 kpps  rDoS         local=19/main=123946
Quoted 7 lines

As seen fib_hlist is catastrophe for large routing tables as expected but performs surprisingly well for ordinary routing tables so it should be fine for most hosts and servers. The patch has config option to select FIB.

Probably we soon want to specify differnt lookup schemes for different tables say for local table fib_hash or fib_hlist. While for large main table fib_hash2/fib_trie would be better option.

Great patch! I wanted to do something like this for a long time :/ It is a good solution for 99.999% of all users who never have more than a few routes.

Random comments while reading the code:

I would perhaps add a printk that warns the user if there are more than 10 routes or so to use a different FIB.

Also I would try to replace the write locks with normal spinlocks. read/write locks should not be needed for the use case of a normal client who basically never changes the routing table, and normal spinlocks are more friendly to modern cache coherency protocols.

With only a few routes it is overkill to have two kmem caches, which both need at least a page each. With 10-20 routes you waste half the memory because of that. Better use a single slab cache for both object types or just kmalloc.

Now we only need support for loadable fibs, then distributions could use this too. Loadable ones should be pretty easy, as long as you dont try to make them unloadable. The later would need a lot of reference counting in fast paths, which would be probably a bad idea. And losing that capability is not a big issue.

-Andi

#2 lore raw
Quoted 8 lines · Andi Kleen

Great patch! I wanted to do something like this for a long time :/ It is a good solution for 99.999% of all users who never have more than a few routes.

Random comments while reading the code:

I would perhaps add a printk that warns the user if there are more than 10 routes or so to use a different FIB.

When we find the break-even point we can a print warning at insertions above this point. A minor problem.

Quoted 4 lines

Also I would try to replace the write locks with normal spinlocks. read/write locks should not be needed for the use case of a normal client who basically never changes the routing table, and normal spinlocks are more friendly to modern cache coherency protocols.

Interesting. I'll guess this goes for all FIB variants. Needs some experimentation.

Quoted 4 lines

With only a few routes it is overkill to have two kmem caches, which both need at least a page each. With 10-20 routes you waste half the memory because of that. Better use a single slab cache for both object types or just kmalloc.

Doable. slab objects are nice & easy to monitor during development.

Quoted 3 lines

Now we only need support for loadable fibs, then distributions could use this too. Loadable ones should be pretty easy, as long as you dont try to make them unloadable.

First step yes. Also we need hi-pref system to have multiple FIB variants. Just attack it if got some ideas.

Quoted 3 lines

The later would need a lot of reference counting in fast paths, which would be probably a bad idea. And losing that capability is not a big issue.

Yes leave that out for now.

Cheers.

					--ro
#3 lore raw
In reply to Andi Kleen
Quoted 16 lines · Andi Kleen
Quoted 5 lines · Robert Olsson

Hello!

fib_hlist is the smallest and simpliest routing algo we could think of it's just a sorted (h)list.

Quoted 8 lines

routing (FIB lookup) performance. dst hash is not used.

    fib_hlist   fib_hash  test        routing table size 
    -----------------------------------------------------
    444 kpps    433 kpps  Single flow. local=19/main=5 entries
    433 kpps    431 kpps  rDoS.        local=19/main=5
    0.2 kpps    198 kpps  rDoS         local=19/main=123946
Quoted 4 lines

Great patch! I wanted to do something like this for a long time :/ It is a good solution for 99.999% of all users who never have more than a few routes.

Great patch it is - but why do you say "99.999% of all users" feel they would love this? Clearly perfomance at the low routes area is not something that is a huge difference against standard fib. And you suffer miserably at latge route size.
Is it memory consumption you are thinking of?

cheers,
jamal

#4 lore raw
Quoted 2 lines

Great patch it is - but why do you say "99.999% of all users" feel they would love this? Clearly perfomance at the low routes area is not

What I wanted to say is that 99.999% of all users dont need the cisco grade BGP4 capable standard FIB, it is a just wasted complexity and memory for them.

Quoted 3 lines

something that is a huge difference against standard fib. And you suffer miserably at latge route size.
Is it memory consumption you are thinking of?

Yes, and complexity.

-Andi

#5 lore raw
In reply to Robert Olsson
Quoted 13 lines · Robert Olsson

Hello!

fib_hlist is the smallest and simpliest routing algo we could think of it's just a sorted (h)list.

routing (FIB lookup) performance. dst hash is not used.

    fib_hlist   fib_hash  test        routing table size 
    -----------------------------------------------------
    444 kpps    433 kpps  Single flow. local=19/main=5 entries
    433 kpps    431 kpps  rDoS.        local=19/main=5
    0.2 kpps    198 kpps  rDoS         local=19/main=123946
Quoted 4 lines

As seen fib_hlist is catastrophe for large routing tables as expected but performs surprisingly well for ordinary routing tables so it should be fine for most hosts and servers. The patch has config option to select FIB.

Probably we soon want to specify differnt lookup schemes for different tables say for local table fib_hash or fib_hlist. While for large main table fib_hash2/fib_trie would be better option.

From a distribution[1] point of view, a boot time option would be much better than choosing at compile time. Boot time plus a kconfig multiple selection list would be even better. Another perhaps even more user friendly option would be setting it runtime using f.ex. iproute, but I guess that could end up messy..

1. goes for both "a GNU/Linux distribution" and kernel image distribution in a production network

#6 lore raw
Quoted 9 lines · Andre Tomt
Quoted 3 lines

Probably we soon want to specify differnt lookup schemes for different tables say for local table fib_hash or fib_hlist. While for large main table fib_hash2/fib_trie would be better option.

From a distribution[1] point of view, a boot time option would be much
better than choosing at compile time. Boot time plus a kconfig multiple selection list would be even better. Another perhaps even more user friendly option would be setting it runtime using f.ex. iproute, but I guess that could end up messy..

Yes I'll guess kernel config would be the first step. Also we need to find out if there are any useful options to current FIB. Which is very general purpose.

Anyway we have a cleaner interface to FIB also we have some new FIB options. Which should be a step forward and an advantage for linux and will hopefully lead to more development and understanding and so that Linux will used for development in this area. We will also lead to better understand the dst hash and FIB trade off.

Experiences from tests or use are very welcome.

Cheers.

					--ro