From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Thomas Hallgren <thhal(at)mailblocks(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Reasoning behind process instead of thread based |
Date: | 2004-10-27 20:36:16 |
Message-ID: | 20041027203616.GE17293@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-10-27 20:36:34 | Re: Reasoning behind process instead of thread based |
Previous Message | Thomas Hallgren | 2004-10-27 20:10:05 | Re: Bug or stupidity |