[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Hyper-threading (was Re: ext3 or xfs for desktop laptop)

On Sat, Jun 10, 2006 at 10:14:41PM -0500, Ron Johnson wrote:
> Nate Bargmann wrote:
> > I have been considering an HT based machine and would like to
> > learn of any potential pitfalls.
> The h/w emulates 2 CPUs.  Thus, even more than a single CPU
> switching contexts, the HT-enabled CPU adds the overhead of trying
> to pretend it's 2 CPUs.
> Remember: the CPU only has X amount of processing power.

This is a bit simplistic.  Hyper-Threading (or more correctly,
simultaneous multithreading (SMT)) is almost always a win because at
any given time a CPU is often waiting for other stages of the
pipeline to complete before it can progress with what it is being
tasked to do.  By having multiple threads of execution it can be
getting on with something useful more of the time.

Of course, unless the software being run is paralellizable then very
little gains will be realised, but the execution part should never
actually get slower.  There have been bugs in the Pentium 4
architecture that have caused various software to run slower under
hyperthreading, and lack of paralellism can lead to no discernible
benefit, but the concept of SMT when done right has no downside from
the point of view of a CPU executing instructions.

Choosing which thread to execute in the CPU does not involve a
context switch or any sort of overhead as you suggest, as each stage
of the instruction pipeline has duplicated registers which are loaded
simultaneously at no additional cost.  At each stage the CPU can
execute either thread/queue at full speed depending on which is
ready to be executed.

Now, where real problems can manifest is the parts of the CPU that
are shared between both threads, e.g. the on-CPU caches.  In a worst
case one thread can be loading lots of data into the cache, then the
other thread can be throwing it away and loading its own, resulting
in them both blocking each other's execution.

In the end the only way to be sure is to benchmark the system under
typical load in both configurations, but SMT can't be dismissed 
as greater parallelism becomes increasingly important.


http://strugglers.net/wiki/Xen_hosting -- A Xen VPS hosting hobby
Encrypted mail welcome - keyid 0x604DE5DB

Attachment: signature.asc
Description: Digital signature

Reply to: