Re: Reasoning behind process instead of thread based - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Reasoning behind process instead of thread based
Date
Msg-id 20041027203616.GE17293@svana.org
Whole thread Raw
In response to Re: Reasoning behind process instead of thread based  (Thomas Hallgren <thhal@mailblocks.com>)
Responses Re: Reasoning behind process instead of thread based
List pgsql-general
On Wed, Oct 27, 2004 at 10:07:48PM +0200, Thomas Hallgren wrote:
> >Threaded servers have one main advantate:
> >Threads are lightweight processes and starting a new thread is faster
> >than starting a new executable.
> >
> A few more from the top of my head:

A lot of these advantages are due to sharing an address space, right?
Well, the processes in PostgreSQL share address space, just not *all*
of it. They communicate via this shared memory.

> 1. Threads communicate much faster than processes (applies to locking
> and parallel query processing).
> 2. All threads in a process can share a common set of optimized query plans.

PostgreSQL could do this too, but I don't think anyone's looked into
sharing query plans, probably quite difficult.

> 3. All threads can share lots of data cached in memory (static but
> frequently accessed tables etc.).

Table data is already shared. If two backends are manipulating the same
table, they can lock directly via shared memory rather than some OS
primitive.

> 4. In environments built using garbage collection, all threads can share
> the same heap of garbage collected data.
> 5. A multi-threaded system can apply in-memory heuristics for self
> adjusting heaps and other optimizations.
> 6. And lastly, my favorite; a multi-threaded system can be easily
> integrated with, and make full use of, a multi-threaded virtual
> execution environment such as a Java VM.

I can't really comment on these.

I think PostgreSQL has nicely combined the benefits of shared memory
with the robustness of multiple processes...
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: Thomas Hallgren
Date:
Subject: Re: Bug or stupidity
Next
From: Tom Lane
Date:
Subject: Re: Reasoning behind process instead of thread based