Why did disabling hyperthreading make my server slower?

Solution 1:

Your Ruby program did not use 2x the CPU time when running with HT disabled. Rather, as it maximizes one core out of two total cores, gnome-system-monitor will report as the utilization as 50%. If, due to HT, the system reports four total cores, one core out of four would be 25%.

Disabling HT did cause more variation in your results because less resources were available: recent Intel (or AMD) cores are quite wide, so additional threads are often useful to extract 10-20% more aggregate performance. If some background process was automatically executed during the test runs, the system without HT is prone to more variance and lower total throughput.

Solution 2:

I wanted to see if disabling hyperthreading benefits a programming language that runs on single thread.

I don't know how cutting the number of cores would improve performance, even for a single threaded app. When hyperthreading is enabled, your cpu is running with 4 virtual cores. A single threaded app using all the cpu it can would use 25% of the available CPU. When you disabled hyperthreading, you took the number of cores down to 2. Now that single threaded app can use 50% of the available CPU.

Ruby isn't using 2x the CPU, it's that you have 1/2 the CPU available when you disable hyperthreading. If you have a large cup 1/4 full of water and pour it into a smaller cup that becomes 1/2 full of water, you still have the same amount of water.

I have even ran the test on my laptop, which takes around twice the time it took on my computer. But the result is identical: disabling hyperthreading doesn't help the process to do better. And even worse, my laptop gets a bit slower when multitasking.

Yes, you are taking away about 1/2 the power of your CPU. That can make the Ruby thread run slower also. Say you have 3 threads that want to be running at the same time in addition to your Ruby thread. If you cut the virtual cores down to 2, it's more likely that your Ruby thread will be paused at least a little to let another thread have sime time.