Social media

Optimizing the mining of monero on a multithreaded CPU

Author: LB 2021-04-29 3503

Monero was released 7 years ago and it took roughly 3 years until the market started appreciating the cryptocurrency. In 2021, the market price of monero has surpassed the $400 level and seemingly an increasing number of investors is shifting their attention to this digital asset. The technological subtleties behind the currency are as interesting as its recent price rally. Monero is one of the few cryptos that can be mined using consumer CPUs and one doesn’t have to buy expensive GPUs or ASIC miners when he wants to join the mining network. Therefore I found the mining of monero a very convenient process to benchmark and I decided to measure the mining performance of a Intel(R) Xeon(R) E5-2666 v3 CPU. Let’s see the details!

One of the most popular monero miners is called xmrig. If you have a fresh Ubuntu installed on your computer, your first step should be to update the OS. You can do this with the following command:

$ sudo apt-get update && sudo apt-get install build-essential cmake libuv1-dev libmicrohttpd-dev libssl-dev -y

Next, let’s download xmrig from the official Github repository:

$ git clone

And now we can enter the directory and compile the source code using the following commands:

$ cd xmrig/cmake && cmake .. -DWITH_HWLOC=OFF && make -j8

This should compile the xmrig source using 8 threads. If you have more threads (or CPU cores) in your system, you can change the last flag.

As soon as the compilation is over, you can run the miner using the following command:

$ sudo ./xmrig

But before this, you should create or copy a configuration file next to the miner and its name should be config.ini. You have to set your monero wallet’s address in the file and don’t forget to set your mining pool’s address in the file as well. Now if you want to set the number of threads used by the miner, you should change the following line in the configuration file:

"rx": [-1, -1],

So for example if you see two minus ones, it means that the xmrig would be using 2 threads to mine monero. At this point, my question was how to set this number? I was using a virtual machine in the AWS cloud with 32 vCPUs so at first, I naively thought that setting 32 minus ones in this line should give me the best hashrate. I launched the miner on 36 threads and I got 4827.5 Hs/s on this CPU. I couldn’t say that it was bad, but nor did I know whether this was the optimal choice. So I decide to plot the connection between hashrates and the number of threads. I started with 1 thread and I increased the number of threads up to 36.

If you want to know the optimal number of threads for monero mining on your multithreaded CPU, you should use the following command:

$ lscpu

This is going to print out many interesting data about your CPU, but you should focus on the following two lines:

Core(s) per socket: 9
Socket(s): 2

So in my case, Intel(R) Xeon(R) E5-2666 v3 CPU has 9 cores per socket with 2 sockets. This means that my CPU has 18 cores and this equals the optimal number of threads for monero mining. Therefore, in order to get the most performance from this CPU the optimal setting would be this:

"rx": [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ],

On 18 threads, the miner was mining monero with 8270.8 Hs/s and this is the optimal hashrate value for an Intel(R) Xeon(R) E5-2666 v3 CPU. This cannot be increased even if you specify a higher number of threads. Rather, the performance would deteriorate. I measured the monero mining hashrate with different number of threads and I got the following graph:

Number of threads Vs. Monero mining hashrate on Intel(R) Xeon(R) E5-2666 v3 CPU

So even if you rent 36 vCPUs from Amazon, you wouldn’t be able to utilize each of them to mine monero. This is because one monero mining process should be run on a single CPU core and multithreading on the same core influences the mining performance significantly. Multithreading on the same CPU core could result in increased performance in rare cases when there is a heavy I/O process and one thread can proceed with its execution while the other thread is writing data between the CPU and the memory. As the mining of monero hasn’t got these peculiarities, the ideal number of threads usually equals the number of physical cores on a CPU. If you want to optimize your monero miner and you don’t know the specification of your hardware you can start from 1 thread and then gradually increase the number of threads until you notice performance degradation and this should give you the ideal number of threads. If you know the number of physical cores you have, you don’t even have to do this analysis.

Have fun with mining monero! Reach out on Whatsapp (+36 30 8316972) if you want to know more on cryptos.

Interesting entries


Best GPUs to mine ethereum in 2022


Dual mining ethereum and toncoin on RTX 3060Ti and RTX 3070Ti LHR


Profiling the RTX 3060 Ti and its memory transfer rate


Core clock settings for RTX 3060 Ti when mining Ethereum


Core clock settings for RTX 3070 Ti Founders Edition when mining ethereum