Linux – Should I disable hyperthreading when concerned about performance of single-threaded applications

hyperthreadinglinuxmultiprocessorparallelismperformance

I use a i5-2410M processor, which is setup to do hyperthreading by default on my laptop. Considering that this is a 2-core processor, this means it can do 4 threads at a time. This also means that single-threaded applications only use a maximum of 25% of processing power, and I would rather have them max at 50% instead. Will disabling hyperthreading have adverse effects (this is a development machine and runs a desktop)? Am I even reading top properly?

Best Answer

With hyper threading with single threaded applications, if you have two of them running you'll see a boost in speed. Hyperthreading means that the CPU starts processing a second thread (whether two threads from a multi-threaded application or two single threaded applications) before the first thread finishes whatever it was doing. Disabling this effectively means that you've cut your CPU capacity in half (but not really, HT will boost by about 30%, but I'm talking about what top tells you), which is why a thread would now show as 50% in top rather than 25%.

Some more explanation:

This doesn't mean, however, that the vast majority of today's applications won't see gains from Hyper-Threading. Even single-threaded apps can reap performance benefits from Hyper-Threading, as long as more than one app is running at the same time (in other words, multitasking). While one application is sending its streams (threads) to one logical processor, a second application is simultaneously sending its streams to the second logical processor. However, if you run only one single-threaded application, you won't see performance gains with Hyper-Threading. In fact, because of the overhead associated with managing the two logical processors of Hyper-Threading, it's even possible to see some performance degradation when running only a single-threaded app.

With a booted UNIX system you're running at least the kernel, init and a shell. You're always multitasking. In all practical ways HT will always benefit you.

Related Question