libkse "wieght"

Daniel Eischen eischen at vigrid.com
Sat Jul 26 07:36:48 PDT 2003


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



More information about the freebsd-threads mailing list