option for large routing hash
Subsystems (2)
PATCH 1/1 option for large routing hash
Hello!
I think patch should be useful as it helps performance a lot during high flow load. I have some numbers if you are interested.
Cheers.
--ro
ipv4/Kconfig renamed from ipv4/Kconfig.orig +13 -0
@@ -75,6 +75,19 @@ If unsure, say N. +config IP_ROUTE_LARGE_HASH + bool "IP: large routing hash" + ---help--- + Say yes to increase the number of dst hash buckets. Most likely you + are running a server or router with lots of flows. Saying yes + will increase used dst hash 8 times typically from 16Kbytes to 128 + Kbytes on a 256Mbytes system. + + dst hash is otherwise tunable via /proc/sys/net/ipv4/route/ + Monitoring can be done with rtstat utility this comes with iproute2. + + If unsure, say N. + config IP_ROUTE_FWMARK bool "IP: use netfilter MARK value as routing key" depends on IP_MULTIPLE_TABLES && NETFILTER
ipv4/route.c renamed from ipv4/route.c.orig +3 -0
@@ -2747,6 +2747,9 @@ goal = num_physpages >> (26 -PAGE_SHIFT ); +#ifdef CONFIG_IP_ROUTE_LARGE_HASH + goal <<=3 ; +#endif for (order =0 ; (1UL << order) < goal; order++)/* NOTHING */ ;
Quoted 2 lines · On Tue, 9 Dec 2003 16:09:07 +0100 Robert Olsson <[email protected]>…
I think patch should be useful as it helps performance a lot during high flow load. I have some numbers if you are interested.
I'm very hesitant about this, and it is not because I don't believe that it brings better performance in your tests on your machines :)
Recently there was a thread on linux-kernel by the folks, such as Jes, working on super-duper-huge NUMA boxes and how big the hash tables get sized to on these machines.
In some of their configurations it was trying to allocate 1GB TCP hash tables or something totally rediculious like this.
The problem with all of our current algorithms for size selection is that it considers only one parameter when there are actually two.
It considers currently only relative memory consumption. It needs to also consider hard limits that exist for useful hash table sizes.
There is a point at which hash table size exceeds it's usefulness in that the gains you are getting from the O(1) lookup are offset by the fact that the access to the hash table heads are constantly taking cpu cache misses.
You've obtained good results in your tests with a _specific_ hash table size for the routing cache, but the algorithm you are proposing for the kernel computes things relative to the amount of memory in the machine. It cannot be a function of only this parameter.
Do you see my point?
Quoted 4 lines · David S. Miller
There is a point at which hash table size exceeds it's usefulness in that the gains you are getting from the O(1) lookup are offset by the fact that the access to the hash table heads are constantly taking cpu cache misses.
Yes.
Quoted 6 lines
You've obtained good results in your tests with a _specific_ hash table size for the routing cache, but the algorithm you are proposing for the kernel computes things relative to the amount of memory in the machine. It cannot be a function of only this parameter.
Do you see my point?
I do. Lets look at experiment to start with also we seen people trying to use in real hi-flow environments. pktgen is sending 32 kflows with flowlen 10 packets (64 byte) at 2 * 300 kpps on into a router. Packet streams 2 * 1M packets. TX OK gives thoughput.
And cache settings max_size=262144 gc_thresh=32768 gc_elastity=8 for both setup.
IP: routing cache hash table of 4096 buckets, 32Kbytes
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flags
eth0 1500 0 2671635 9583466 9583466 7328370 10 0 0 0 BRU eth1 1500 0 12 0 0 0 2671640 0 0 0 BRU eth2 1500 0 2623413 9556039 9556039 7376591 4 0 0 0 BRU eth3 1500 0 1 0 0 0 2623412 0 0 0 BRU
rtstat sample (truncated)
size IN: hit tot mc no_rt bcast madst masrc
35320 62700 88890 0 0 0 0 0
Look due to the cache size and GC it looks like a route DoS attack. We have very little use of the hash as tot(long path) > (cache) hit. Lots of linear seach in hash. And tot+hit gives the pps throughput 152 kpps. It's easy to characterize as a DoS attack but flowlen is 10 packets.
----------------------------------------------------------------------------
IP: routing cache hash table of 32768 buckets, 256Kbytes
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flags
eth0 1500 0 4382945 9293599 9293599 5617062 13 0 0 0 BRU eth1 1500 0 16 0 0 0 4381291 0 0 0 BRU eth2 1500 0 4290290 9292399 9292399 5709713 3 0 0 0 BRU eth3 1500 0 1 0 0 0 4288727 0 0 0 BRU
rtstat sample (truncated)
size IN: hit tot mc no_rt bcast madst masrc
212976 212665 52703 0 0 0 0 0
We see cache is now used as hit > tot and we get a performance jump from 152 to 265 kpps.
Just as you said this was the experiment. I'll stop here for now.
Cheers.
--ro
Quoted 1 line · On Tue, 9 Dec 2003 23:28:31 +0100 Robert Olsson <[email protected]>…
IP: routing cache hash table of 4096 buckets, 32Kbytes
...
Quoted 1 line
And tot+hit gives the pps throughput 152 kpps.
...
Quoted 1 line
IP: routing cache hash table of 32768 buckets, 256Kbytes
...
Quoted 4 lines
We see cache is now used as hit > tot and we get a performance jump from 152 to 265 kpps.
Just as you said this was the experiment. I'll stop here for now.
Thanks for the data.
I would eventually like an algorithm that uses a min/max range. Perhaps something like:
const unsigned long rthash_min = PAGE_SIZE:
const unsigned long rthash_max = PAGE_ALIGN(512 * 1024 *
sizeof(struct rt_hash_bucket));
unsigned long rthash_choose_size(unsigned long num_physpages)
{
unsigned long goal;
goal = num_physpages >> (23 - PAGE_SHIFT);
if (goal < rthash_min)
goal = rthash_min;
if (goal > rthash_max)
goal = rthash_max;
return goal;
}It's a combination of your goal computation adjustment along with sanity limits, that's all.