From owner-freebsd-hackers Thu Apr 27 15:49:40 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from obie.softweyr.com (obie.softweyr.com [204.68.178.33]) by hub.freebsd.org (Postfix) with ESMTP id 7921837BC96 for ; Thu, 27 Apr 2000 15:49:36 -0700 (PDT) (envelope-from wes@softweyr.com) Received: from softweyr.com (Foolstrustidentd@obie.softweyr.com [204.68.178.33]) by obie.softweyr.com (8.8.8/8.8.8) with ESMTP id QAA16222; Thu, 27 Apr 2000 16:49:04 -0600 (MDT) (envelope-from wes@softweyr.com) Message-ID: <3908C3FE.ABD80977@softweyr.com> Date: Thu, 27 Apr 2000 16:49:34 -0600 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 4.0-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: A G F Keahan Cc: "Richard Seaman, Jr." , Jason Evans , freebsd-hackers@FreeBSD.ORG Subject: Re: Multithreaded server performance References: <3903AEA6.FA7CBBAB@freenet.co.uk> <20000423212115.E31925@sturm.canonware.com> <20000424164405.G370@seaman.org> <390501AB.D185646E@freenet.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG A G F Keahan wrote: > > > On Sun, Apr 23, 2000 at 09:21:15PM -0700, Jason Evans wrote: > > > > > > This design isn't ideal on any OS, but the fact that you do significant > > > processing every time a request arrives on a socket probably hides most of > > > the inefficiency due to thread switching and lack of cache locality due to > > > many thread stacks. > > Can you suggest a better design for this type of server application > under FreeBSD? Perhaps a combination of forking (or pre-forking) and > threads? Preallocate a number of threads that yeilds adequate peformance and feed work to the threads via IPC mechanisms. When the thread finishes its work, rather than exiting, it just waits for another work unit. A simple way to do this is via a queue, or via a shared memory pool for each thread and a "go" semaphore. This avoids the overhead of thread startup and shutdown for every client connection. -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message