# Enabling Hyperthreading on Sandy Bridge



## jkcarrol (May 25, 2011)

I just wanted to share my results in comparing a few different workloads with and without hyperthreading on a Core i7 2600k (Sandy Bridge) processor. The short summary is that I have so far found all the things I have thrown at it faster with HTT enabled.

Attached is a screen shot of the raw data (table) as well as a quick graph of the % speed up when enabling hyperthreading on this system for a few workloads. I've decided to keep hyperthreading enabled on this server, since I haven't found a workload that preforms worse with it enabled.

If there are other things folks would like me to try running and add to my results, I'd be happy to do additional testing. Anyway, I hope this data can help people make a decision between two CPUs that have or don't have hyperthreading or decide whether to turn it on or leave it off if you already have a Sandy Bridge processor with Hyperthreading support.


----------



## SirDice (May 26, 2011)

You should indeed see an improvement, but obviously not on single threaded applications.

Just for reference, the reason HTT is turned off by default is because of a few security issues.
http://kerneltrap.org/node/5103
http://www.daemonology.net/hyperthreading-considered-harmful/
http://security.freebsd.org/advisories/FreeBSD-SA-05:09.htt.asc

Not sure if this is still valid for the newer cores though.


----------



## jkcarrol (May 26, 2011)

SirDice said:
			
		

> You should indeed see an improvement, but obviously not on single threaded applications.



Right, I realize this is only going to help multi-threaded things or with multiple processes. The workloads I happen to use are mostly threaded. Note that I am not seeing a slow down for single threaded things with HTT enabled. I can't recall if that was the case with older versions of HTT (e.g. on the Pentium 4/Pentium D). The reason I brought this up is I remember HTT actually hindered many/most workloads on FreeBSD at the time. So I was quite surprised when all my tests were faster with HTT enabled. 



> Just for reference, the reason HTT is turned off by default is because of a few security issues.
> http://kerneltrap.org/node/5103
> http://www.daemonology.net/hyperthreading-considered-harmful/
> http://security.freebsd.org/advisories/FreeBSD-SA-05:09.htt.asc
> ...



Yes, I'm aware of the security concerns. I'm not sure if they are still valid for the newer renditions of hyperthreading, but even if they are, it's a calculated risk on this server I'm willing to take. I think it's relatively low risk, but it's absolutely something people should consider when deciding whether to use HTT or not. Do you know if there is a POC or a way to check if these new chips are still susceptible to this attack vector?


----------



## SirDice (May 27, 2011)

The paper by Colin Percival contains some (assembly) code but it's mostly dry theory.


----------



## Terry_Kennedy (May 28, 2011)

SirDice said:
			
		

> Just for reference, the reason HTT is turned off by default is because of a few security issues.
> 
> Not sure if this is still valid for the newer cores though.



/usr/src/sys/amd64/amd64/mp_machdep.c has had hyperthreading back on since Revision 1.287.2.2 Wed Nov 28 23:24:06 2007 UTC (and similarly for i386), which I'm pretty sure means that it is on by default for FreeBSD 7.0 and later. The commit message was:



			
				 cperciva@ said:
			
		

> Back out previous commit]


----------

