From owner-freebsd-net Mon Jul 2 16:52:28 2001 Delivered-To: freebsd-net@freebsd.org Received: from warspite.cnchost.com (warspite.concentric.net [207.155.248.9]) by hub.freebsd.org (Postfix) with ESMTP id 1F14C37B401; Mon, 2 Jul 2001 16:52:25 -0700 (PDT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (adsl-209-204-185-216.sonic.net [209.204.185.216]) by warspite.cnchost.com id TAA11491; Mon, 2 Jul 2001 19:52:24 -0400 (EDT) [ConcentricHost SMTP Relay 1.13] Message-ID: <200107022352.TAA11491@warspite.cnchost.com> To: Jeffrey Hsu Cc: freebsd-net@freebsd.org Subject: Re: fastforwarding? In-reply-to: Your message of "Mon, 02 Jul 2001 13:39:54 PDT." <0GFV00LBT5EXRH@mta8.pltn13.pbi.net> Date: Mon, 02 Jul 2001 16:52:24 -0700 From: Bakul Shah Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org > > a stock freebsd system can't do more than 20K ~ 100K pkts/second due to > > many bottlenecks > > I'd be interested in knowing where those bottlenecks were and fixing them. > I currently hit the packets/sec limit running on gigabit ethernet cards, but > so far I've been blaming it on the relatively old firm-ware based Tigon II NIC > and not the BSD stack. > > > Even if it takes 0 ns to do a route lookup, > > So are you saying route lookup is not the bottleneck? The radix tree lookup is definitely slow. My point was that you need to look at the entire forwarding path to improve performance even if you replace the radix tree with something faster. For instance, - interrupt overhead as Luigi (and others) have noted - an input packet is queued twice: once on the device queue and once on the ip input queue. - If your router has a many interfaces, the input packet is checked against the directed broadcast address for every interface. - mbuf processing. - processing the same packet multiple times. For example, checking that 127.x.x.x does not come in from outside. bpf. ipfilter, ipfw, dummynet etc. - The cost of modularity and layering. Probably better to use inlining judiciously so that the compiler can flatten out call sequences. - The common case is not optimized. For a router the common case is forwarding a packet, for a host it is not. You need two different routines optimizing each case and plug in the right function, depending on the application. Similarly for firewalls etc. you have different common cases. Not rocket science, mostly compiler tricks! Just what you can do by removing duplication, knowing and optimizing the common case, code movement (move processing from per packet to route add/delete etc.), use brute force (switch or jumptable instead of a bunch of if-then-elses), strength reduction (use a cheaper operation), all based on measuring hotspots. Most of this is just plain old boring engineering so likely there are not many papers on them :-) > > So *overall* you are better off using a trie algorithm. > > I'm thinking of the probability-shifted lc-trie algorithm described in > http://klamath.stanford.edu/~pankaj/research.html > Do you have a better algorithm in mind? That or even simpler algorithms will suffice. Once you bring the cost of route lookup below 1 to 5% it doesn't matter much. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message