From owner-freebsd-net Mon Feb 11 11:26:49 2002 Delivered-To: freebsd-net@freebsd.org Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by hub.freebsd.org (Postfix) with ESMTP id 674F537B402 for ; Mon, 11 Feb 2002 11:26:45 -0800 (PST) Received: by elvis.mu.org (Postfix, from userid 1192) id 2AD3210DDFB; Mon, 11 Feb 2002 11:26:45 -0800 (PST) Date: Mon, 11 Feb 2002 11:26:45 -0800 From: Alfred Perlstein To: Mike Silbersack Cc: Tariq Rashid , freebsd-net@FreeBSD.ORG Subject: Re: squeeze more performance out of natd? Message-ID: <20020211112645.F63886@elvis.mu.org> References: <20020211130512.S84750-100000@patrocles.silby.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020211130512.S84750-100000@patrocles.silby.com>; from silby@silby.com on Mon, Feb 11, 2002 at 01:08:07PM +0000 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 * Mike Silbersack [020211 11:05] wrote: > > On Mon, 11 Feb 2002, Tariq Rashid wrote: > > > some tests seems to show that natd's cpu load goes up because we have a > > large file descriptor set for select() - this is more of a problem than the > > kernelspace/userland packet traversal. the traffic its handling is something > > like 1500 low traffic tcp connections to a single server port. > > > > from doing some rtfm-ing i see that select() is not very scalable - not > > good for large fd sets and not good if they are nearly alwats ready for > > reading. > > The best way to improve performance would probably be to rewrite natd to > use kqueue instead of select. I'm not sure how difficult this would be, > you might wish to talk to jlemon if you have any questions on the best way > to tackle the project. That's what I thought initially, however the problem is that each packet requires at least a select(2) then recvfrom(2) and then possibly a sendto(2). The select(2) loop is particulary niave as the dispatched functions will only pull one packet from the socket instead of looping until the outstanding data is removed. Yes, another way would be to loop doing recvfrom's until EAGAIN is returned, I suspect this may give at least a 2 fold increase in performance and is trivial to accomplish. another would be to figure out a way to pull multiple packets via some recvfrom-like call that can return multiple sockaddrs, this would probably also give a very nice performance improvement. another way to improve it slightly would be to use kevent, failing that, there's always moving it into the kernel where the perf would most likely get better by several orders of magnitude by avoiding copies and userspace/kernel context switching. -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message