Re: Reasoning behind process instead of thread based

From: Thomas Hallgren <thhal(at)mailblocks(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Reasoning behind process instead of thread based
Date: 2004-10-28 11:02:33
Message-ID: thhal-0U2pcArWz3kA1pH2y1znYG6XK0Y/Z8I@mailblocks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout wrote:

>Now you've piqued my curiosity. You have two threads of control (either
>two processes or two threads) which shared a peice of memory. How can
>the threads syncronise easier than processes, what other feature is
>there? AFAIK the futexes used by Linux threads is just as applicable
>and fast between two processes as two threads. All that is required is
>some shared memory.
>
>
Agree. On Linux, this is not a big issue. Linux is rather special
though, since the whole kernel is built in a way that more or less puts
an equal sign between a process and a thread. This is changing though.
Don't know what relevance that will have on this issue.

Shared Memory and multiple processes have other negative impacts on
performance since you force the CPU to jump between different memory
spaces. Switching between those address spaces will decrease the CPU
cache hits. You might think this is esoteric and irrelevant, but the
fact is, cache misses are extremely expensive and the problem is
increasing. While CPU speed has increased 152 times or so since the
80's, the speed on memory has only quadrupled.

>Or are you suggesting the only difference is in switching time (which
>is not that significant).
>
>
"not that significant" all depends on how often you need to switch. On
most OS'es, a process switch is significantly slower than switching
between threads (again, Linux may be an exception to the rule).

Regards,
Thomas Hallgren

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andy Gimblett 2004-10-28 12:29:02 Interpolation of environment variables in SQL at runtime?
Previous Message Thomas Hallgren 2004-10-28 10:15:35 Re: Reasoning behind process instead of thread based