On Fri, Jul 04, 2008, Rev Simon Rumble wrote:
> I have an Intel Xeon 3 gig CPU and have hyperthreading turned on in the 
> BIOS.  I've been trying to work out what the advantages and 
> disadvantages of this are.

ok.

> The CPU appears as two CPUs to the machine, which means that 
> non-threaded apps don't appear to use the whole CPU.  Is this a correct 
> assumption?  For example, using Devede to convert video, the transcode 

Yes.

> process only uses 50% of CPU in top.  If I run another CPU-intensive 
> process, the CPU usage in top goes close to 100%.

Yes.

> So would I be correct in assuming that hyperthreading is useful for 
> keeping the system responsive under load, but if running single-threaded 
> CPU-intensive processes, it'll run faster without hyperthreading?

Mostly.

You need to understand what hyperthreading is. Imagine you can break up
your CPU into building blocks. You've got logical control blocks, integer
math blocks, instrution execution blocks, all that kind of jazz.
You won't be using -all- of the execution blocks all of the time - code
is generally not 100% optimised and isn't keeping the whole CPU busy.
100% CPU usage on a single code/thread is actually not "100% of the CPU
is busy", its "There's no way to do any further work without causing some
of the work to sit in a queue and wait."

Hyperthreading is a way to make two "threads" of execution share the same
building blocks. The two threads can then try and "do" more work by using
the blocks unused by the other.

Whether its faster or slower depends on your kind of work. Some kinds of
work involves keeping almost all of the blocks busy - adding a second
thread and trying to run other jobs actually slows both of them down.

For example (and I apologise for becoming "technical") - if you have
blocks A,B,C,D, and your job involves work being done on A+B and the
results being consumed by C with all of the blocks staying "active"
(ie, you don't have A+B doing work, then they sleep whilst C does some
work, then C sleeps whilst A+B does work) then your CPU may show up as
100% busy even though block D is sitting there idle.

If you introduce a second thread via hyperthreading and it wants A+D
to do work, then you've got a problem - thread 1 wants to fully use
A+B+C but every time the second thread wants to do work it wants A+D
and A can't do twice the work :) So whenever thread 1 is running
(A+B+C) then thread 2 can't run; whenever thread 2 is running (A+D)
then thread 1 can't run; this shows up as both CPUs running at 100%
but results in less work being done.

Some kinds of work involves keeping only a few blocks busy - adding a
second thread allows more work to be done without interfering with each
other.



Adrian


-- 
- Xenion - http://www.xenion.com.au/ - VPS Hosting - Commercial Squid Support -
- $25/pm entry-level VPSes w/ capped bandwidth charges available in WA -
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to