Re: Threading NOT working as expected



On Sat, 1 Mar 2008 18:09:32 +0100 Martijn Lievaart <m@xxxxxxxxxxxxxxxx> wrote:

ML> On Sat, 01 Mar 2008 17:04:08 +0100, Peter J. Holzer wrote:
On 2008-02-26 16:39, Ted Zlatanov <tzz@xxxxxxxxxxxx> wrote:
In a multithreaded setup, the CPU has a chance to run several threads
while memory and I/O fetches are happening.

Multithreading won't help for memory fetches. Firstly because CPUs don't
have a way to inform the OS of a slow memory access, and secondly
because the overhead of switching to a different thread would be much
too high for such a (relatively) short wait. There is one exception:
So-called multi-threading CPUs can keep the state of a fixed (and
usually low) number of thrads on the CPU and switch between them. But
these are really just multi-core CPUs which share some of their units.

You are completely right about I/O of course.

ML> Not even. If all those I/Os are going to the same disk, you run the risk
ML> of thrashing, and overall performance goes down instead of up.

That's very application-dependent. Note my original statement: the CPU
has a chance to run several threads while fetches are happening. It
doesn't mean that I/O will work better than way, but that's not a
multithreading problem. The elevator algorithm introduced fairly
recently in Linux kernels (IIRC) addresses this kind of I/O contention
in the right place, outside the application.

Ted
.


Loading