From owner-freebsd-net@FreeBSD.ORG Wed Feb 15 20:31:10 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 192E316A420; Wed, 15 Feb 2006 20:31:10 +0000 (GMT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id B672743D7F; Wed, 15 Feb 2006 20:30:47 +0000 (GMT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.11/8.12.11) with ESMTP id k1FKUhVL029619; Wed, 15 Feb 2006 12:30:43 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.11/8.12.3/Submit) id k1FKUhoe029618; Wed, 15 Feb 2006 12:30:43 -0800 (PST) (envelope-from rizzo) Date: Wed, 15 Feb 2006 12:30:43 -0800 From: Luigi Rizzo To: Andre Oppermann Message-ID: <20060215123043.A29559@xorpc.icir.org> References: <7bb8f24157080b6aaacb897a99259df9@madhaus.cns.utoronto.ca> <711b7ec873f31bc5be50ce477313fac3@madhaus.cns.utoronto.ca> <200602110002.21275.max@love2party.net> <43F38CF5.71C326C1@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <43F38CF5.71C326C1@freebsd.org>; from andre@freebsd.org on Wed, Feb 15, 2006 at 09:20:05PM +0100 Cc: Marcos Bedinelli , Max Laier , Julian Elischer , freebsd-net@freebsd.org Subject: Re: Network performance in a dual CPU system X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Feb 2006 20:31:10 -0000 On Wed, Feb 15, 2006 at 09:20:05PM +0100, Andre Oppermann wrote: ... > >From my profiling with the Agilent tester there seem to be two areas where > the packet filters (ipfw in my test case) burn a lot of CPU per packet. > That is a) setup of lots of packet variables unconditionally at the entry > of ip_fw_chk() no matter whether they get looked at later or not, and b) > the switch() going through all the packet inspection options is for some > reason not optimized by the compiler and burns even more CPU. Some sort > of JIT (as in the new bpf code) which replaces the case testing and jumps > directly to the proper place in the switch statement would go a long way > of making it way more performant. i was expecting some overhead in the initial setting of variables but the cost of the switch() surprises me a bit. did you look at the assembly code produced, or otherwise could you explain a bit more how you think the switch affects performance ? Maybe one could make it cheaper through an indirect function call ? (in the end, instructions are already indexes for a jump table). cheers luigi