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
> 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(at)svana(dot)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.
In response to
pgsql-general by date
|Next:||From: Tom Lane||Date: 2004-10-27 20:36:34|
|Subject: Re: Reasoning behind process instead of thread based |
|Previous:||From: Thomas Hallgren||Date: 2004-10-27 20:10:05|
|Subject: Re: Bug or stupidity|