Improve CPU Monero (XMR) mining by disabling Hyperthreading (HT)

in cryptocurrency •  2 years ago  (edited)

As a follow up to my previous post where I explain how to gain up to 20% performance with large pages, I come with another tip for improving CPU mining speed for monero.

The tip is do not use Intel Hyperthreading.

Hyperthreading (HT) is a feature that allows two threads to run on parallel on a physical core. This feature essentially doubles the number of cores an operating system sees and can schedule tasks. This sounds good but not always, for some applications running two threads on a single core might significantly reduce the single thread performance and diminish any benefits from doubling the number of cores. This is actually the case for monero mining. The performance is actually worse when using the extra threads that come with HT. 

Here are some results showing the detrimental effect has hyperthreading for Monero mining across different Intel CPUs. 


As you can see in the above graph I cover a wide range of parameters like different microarchitectures skylake (i7 6700), haswell (i7 5820K, i74500U), laptop (i74500U) and desktop (6700, i7 5820K) cpus and various core numbers (5820K hexa core, 6700 4core, 4500U dual core).

With 4500U being the only exception, the other two cpus have a severe impact with HT enabled. i7 6700 produces 68% more hashrate with HT disabled while i7 5820K  has 33% higher hashrate with HT disabled.

So, to sumarize the message is don't use the extra cores that come with HT because most likely you will get lower hashrate.

Let's looks ways to avoid HT

1) Disable it from BIOS. This is the easiest way to disable it. Just press DEL or Fwhatever (the key to enter setup should be printed on your screen) at the beginning of your machine's boot and you should find fairly easy the setting for turning on/off HT.

I don't like this solution so much because every time I want to run something that benefits from HT i.e. play a game like battlefield), I have to reboot the PC and change the HT BIOS option.

2) Keep HT enabled but don't use the extra cores for running the monero miner. This is a bit more complicated solution but it is the best one, since this way you won't loose the HT feature for other applications that benefit from it.

Here are the instructions for applying the second solution:

1) Enter BIOS and enable SMT (in case you have it disabled)

2) press alt+ctrl+delete to enter task manager

3) go to performance tab

3a) click on cpu

3b) right click on graph click change graph to, click on logical processors

3c) count the number of processors and divide the number by two.. This is the number of threads you should use for your miner

4) or just read the number of Cores (not logical processors) below the CPU graphs like in the picture below (this picture is from windows 8.1, this picture may be slightly different for other windows OS)


5) Now start your miner

I will use the xmrig miner as an example

Note that other miner should have similar command line options. Basically we need to fine tune two options: the number of threads and the process affinity (the cores in which the miner threads will run)

Go to config.json file

set the "threads": option to the number of cores you found from steps 3/4. Other miners should have similar option for specifying the number of threads.

Now go set the "cpu-affinity" option. This option is really important so you don't end up with two threads running on the same physical core. Usually windows numbering works like this, core 0-1 belong to the first physical core, cores 2-3 belong to the second physical core and etc

So for example in dual physical core system (logical cores 0,1,2,3) to avoid HT you should run the miner on cores 0 and 2 or cores 1 and 3.

"cpuaffinity" option expects core bitmask. Below I provide you the mask to use depending on number of physical cores your system has (or in the other words the number of threads you are going to use)

threads -> affinity

2-> 0x5

4-> 0x55

6-> 0x555

8-> 0x5555


You get the point, for each pair of threads add another 5. Using A character instead of 5 also works e.g.

2-> 0xA

4-> 0xAA

6-> 0xAAA

8-> 0xAAAA

Now in case your miner doesn't support an affinity command line you can specify the process affinity using the "Start" command.

e.g. the below command starts the miner on cores 0,2,4,6,8,10 

START /AFFINITY 0x555  wolf-xmr-miner-v0.4\miner wolf-xmr-miner-v0.4\xmr-cpu.conf 

Also, you can always change a process affinity from the task manager.

To do this (instructions for windows 8.1 and above, for windows 7 the procedure is very similar):

a) press Alt+Ctrl+Del to open Task Manager and go to the Process Tab.

b) Right click on the apllication for which you want to set Processor affinity(in our case your miner process). And select Go to Details

c) Now right click the application and click "Set affinity".

d) Uncheck the "ALL processors" option and select only the cores you want to use. To disable HT just go round robin, e.g. select core 0, don't select core 1, select core 2, don't select core 3 etc

Please consider supporting me as a Steem Witness by voting for me at the bottom of the Witness page; or just click on the upvote button if I am in the top 50:


Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

1 2

Your post instantly made me feel poetic. Someday bitcoin will become greater than gold, a beacon of light in the financial night that's so bitter and cold... Oh I should just stop, here's an upvote for you!

Sure, spending your life savings on MONERO might have been the best thing you’ve EVER done…

But you made the bought XMR, you did it with one thing in mind… SHOOTING FOR THE MOON. XMR has that 10X factor, which you will have to when you wear this shirt in public. You will get the attention of others HODLing XMR, and their girlfriends.

This comfy 100% cotton shirt can be shipped out in a few days.

Check -

looking for a easy way to mine monero from any device go here >

want to know how to be massively successful in crypto go here >