When is it worth enabling hyperthreading?

Bill Moran wmoran at potentialtech.com
Thu Oct 8 10:33:40 UTC 2009

Pierre-Luc Drouin <pldrouin at pldrouin.net> wrote:
> Hi,
> Could someone explain me in which cases it is useful to enable 
> hyperthreading on a machine running FreeBSD 8.0 and in which other cases 
> it is not a good idea? Is that possible that hyperthreading is 
> disadvantageous unless the number of active (non-sleeping) threads is 
> really high?
> For example, if I have an i7 CPU with 4 physical cores and that I run 
> some multi-threaded code that has only 4 threads, it will run almost 
> always (twice) slower with hyperthreading enabled than when I disable it 
> in the BIOS. If I understand correctly, hyperthreading has the advantage 
> of being able to do CPU context switching faster than the OS, but it 
> does this context switching systematically instead of only when 
> requested, so it slows things down unless the number of running 
> (non-sleeping) threads is greater or equal to let say the number of 
> physical threads x 1.5-1.75.

I can't speak to the technical explanation, but I can give you my real-
world experience.

We asked this same question where I worked and had the time and ability
to test it.  What we found:

* With hyperthreading on, workstations were more responsive to concurrent
  tasks.  They weren't particularly faster at executing, but there were
  less incidents of a background task causing the UI to stall or stutter.
* pgbench showed anywhere from 0% - 15% increased throughput.  Kind of
  pathetic, but we never saw a workload on PostgreSQL that was hurt by
  turning hyperthreading on.

Bill Moran

More information about the freebsd-questions mailing list