THREADS and CPU AFFINITY settings are two extremely important settings when mining. Specially with RYZEN processors.
I own a Ryzen 1700X. This AMD CPU have 16 threads and optimizing theses settings give me a big boost. I went from 1000 to 3400 H/S.
Explantations.
By default, XMRIG is mining on all theads. In case of mining XDAG, using all threads is useless and counterproductive.
CPU usage with 16 threads :
Hashrate result in mining with 16 threads :
With Ryzen 1700X, the best performance is 7 threads.
To reach this conclusion, I proceeded by dychtomy : I made measurements over 15 minutes, I started with 16 threads, then 8, then 12, then 4, etc… until I concluded that 7 gave me the best hashrate. It’s a long process, but very useful. Every processor works differently, no absolute generalizations can be made.
In CPU, threads are numbered from zero. In case of 1700X, from 0 to 15.
Threads 0 and 1 should not be used for mining. Specially when mining on Windows. Theses threads are used by OS timers and mains process. Requisitioning them to mine can make the system unstable.
The following threads (2 to 15) should be alternated.
So I set the CPU AFFINITY like this:
- THREADS ON : 2,4,6,8,10,12,14
- THREADS OFF : 0,1,3,5,7,9,11,13,15
To calculate the CPU AFFINITY value, use this website: https://bitsum.com/tools/cpu-affinity-calculator/
You will then have to convert the value to decimal, put it in CONFIG.JSON in replacement of -1 value in “affinity : -1”. Thus, you will force the miner to use these specific threads. Don’t forget to set threads numbers too :
Here is the result. CPU usage with 7 threads and CPU AFFINITY on threads 2,4,6,8,10,12 & 14 :
And the benefit with hashrate mining :
Setting CPU AFFINITY is usefull for CPU with lots of threads. If your CPU have less than 8 threads, this should not be necessary. But make tests, check by yourself.
For CPU having less than 8 threads, the better threads setting should be threads -1. Ex: 4 threads, set 3.
Again, there is no general rules, you should make test and find best configuration for your CPU.
You should find some clue about best threads numbers on XMRIG benchmark website :