Re: Using Threads? - Mailing list pgsql-hackers

From Dan Lyke
Subject Re: Using Threads?
Date
Msg-id 14892.6919.336659.41711@wynand.flutterby.com
Whole thread Raw
In response to Re: Using Threads?  (Adam Haberlach <adam@newsnipple.com>)
Responses Re: Using Threads?  (Bruce Guenter <bruceg@em.ca>)
Re: Using Threads?  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
Adam Haberlach writes:
> Typically (on a well-written OS, at least), the spawning of a thread
> is much cheaper then the creation of a new process (via fork()).

This would be well worth testing on some representative sample
systems.

Within the past year and a half at one of my gigs some coworkers did
tests on various platforms (Irix, Solaris, a few variations of Linux
and *BSDs) and concluded that in fact the threads implementations were
often *slower* than using processes for moving and distributing the
sorts of data that they were playing with.

With copy-on-write and interprocess pipes that are roughly equivalent
to memcpy() speeds it was determined for that application that the
best way to split up tasks was fork()ing and dup().

As always, your mileage will vary, but the one thing that consistently
amazes me on the Un*x like operating systems is that usually the
programmatically simplest way to implement something has been
optimized all to heck.

A lesson that comes hard to those of us who grew up on MS systems.

Dan


pgsql-hackers by date:

Previous
From: Alex Perel
Date:
Subject: INSERT INTO ... SELECT problem
Next
From: Jan Wieck
Date:
Subject: Re: 8192 BLCKSZ ?]