From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 30 12:25:37 2006 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.org Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 238F216A4E5 for ; Wed, 30 Aug 2006 12:25:37 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 26FAD43D55 for ; Wed, 30 Aug 2006 12:25:35 +0000 (GMT) (envelope-from glebius@FreeBSD.org) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.13.4/8.13.3) with ESMTP id k7UCPYK9026655 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 30 Aug 2006 16:25:34 +0400 (MSD) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.sick.ru (8.13.4/8.13.1/Submit) id k7UCPX2g026654; Wed, 30 Aug 2006 16:25:33 +0400 (MSD) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.sick.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Wed, 30 Aug 2006 16:25:33 +0400 From: Gleb Smirnoff To: Martin Eugen Message-ID: <20060830122533.GV76666@FreeBSD.org> References: <966ba91e0608180041v3cfd9dcfh80ef89aab5404f48@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <966ba91e0608180041v3cfd9dcfh80ef89aab5404f48@mail.gmail.com> User-Agent: Mutt/1.5.6i Cc: freebsd-hackers@FreeBSD.org Subject: Re: SOCK_DGRAM optimization needed... X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Aug 2006 12:25:37 -0000 On Fri, Aug 18, 2006 at 10:41:36AM +0300, Martin Eugen wrote: M> I have a simple application, that deals with lots of dgram sockets (UDP). M> Thousands of them. Basically, its purpose is to M> maintain pairs of sockets and when data is received on one of the sockets it M> peeks through it (doing some simple M> statistic calculations) and then forwards it to the other socket. M> Because of the hudge number of reads and writes (probably about a 10 packets M> per second per socket pair) it generates a significant load M> on the system, that I would like to minimize. I'm currently evaluating if it M> would be possible to add simple 'routing' functionality in the socket layer M> in the kernel, because frankly I'm not able to think of anything else. As Robert said you can try to put this into kernel. That is, you can write down a netgraph node, that does the routing. Then connect thousands of ng_ksocket(4) to it. If netgraph(4) survives such a big graph (I hope so), you will get quite fast forwarding. You should also implement a fast ng_findhook method for your 'routing' node, so that it won't cycle through the thousand of hooks. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE