From owner-freebsd-threads@FreeBSD.ORG Sat Jul 26 07:36:48 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 009A737B401; Sat, 26 Jul 2003 07:36:48 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3564143FBD; Sat, 26 Jul 2003 07:36:47 -0700 (PDT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h6QEakax003333; Sat, 26 Jul 2003 10:36:46 -0400 (EDT) Date: Sat, 26 Jul 2003 10:36:46 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: David Xu In-Reply-To: <200307262145.02854.davidxu@FreeBSD.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE cc: freebsd-threads@freebsd.org Subject: Re: libkse "wieght" X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: deischen@freebsd.org List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jul 2003 14:36:48 -0000 On Sat, 26 Jul 2003, David Xu wrote: > On Saturday 26 July 2003 21:00, Petri Helenius wrote: > > First of all, I=B4m very happy with the libkse since a few weeks ago, > > scheduling and signals seem to work for me and the application runs > > smoother than ever, although with only a handful of threads. > > > > I was wondering how "expensive" thread creation and termination designe= d to > > be with libkse, say should I just create and throw away tens or hundred= s of > > threads in a small time or try to "recycle" the worker threads I alread= y > > created?=20 >=20 > With newest libkse source code, I can create 5000 threads and then > pthread_join them in 0.6 seconds on my PIII 1Ghz machine. Although it is > cheap enough to create thread and throw it away, but caching some threads= is=20 > still a good idea. Libkse caches up to 100 threads for you, and throws away any more than that to free(). There is still a bit of set up to do with a libkse cached thread (makecontext(), add the thread to the run queue, etc), but it should be faster than creating a thread from scratch. I think you would have to modify the library to not cache threads (set MAX_CACHED_THREADS to 0 in lipthread/thread/thr_kern.c) in order to really benchmark the difference between the library caching threads and not caching threads. --=20 Dan Eischen