Social media

Mining and profiling monero on a laptop

Author: LB 2021-04-25 507

Monero is one of my favourite cryptocurrencies, mainly because I can use my own PC to mine it and I don’t have to invest crazy amounts of money to buy new mining equipment. Recently, I decided to investigate Monero mining in detail and my goal was to find out the most time consuming part of the cryptocurrency mining process. Xmrig is probably the most popular mining software available both for Windows and Linux. In the following article I’m going to give you a short narrative on the subtleties of Monero mining.

So my first step was to download and install xmrig on my laptop with a Intel(R) Core(TM) i5-8265U CPU. This commodity CPU has a 1 MB L2 cache and a 6.0 MB L3 cache. You can tell that my notebook is for web browsing and not for Monero mining. Nevertheless, I tried to install xmrig on this PC to benchmark my CPU and to find out the most time consuming step of the program.

So I downloaded xmrig-6.10.0 from Github from the following URL: After having obtained the source code, I followed the instructions in the installation manual, I used cmake and make to compile xmrig. Then I created a Monero wallet and obtained a mining pool address. This time I connected to and when I launched my miner I started receiving the chunks from the mining pool to be validated my notebook.

Then I started looking into to code, because I wanted to understand how the RandomX algorithm works and I also wanted to find out the bottleneck in the code. Or in other words, my goal was to shed light upon the connection between the data manipulation that’s happening inside the code and the reported hashrates on

If you want to find out the most time consuming steps in the miner, you should understand how the RandomX algorithm works and for that refer to src/crypto/randomx/randomx.cpp.

The most time consuming part of the mining process is related to the virtual machine initialized and launched by xmrig. At first I thought that the cryptography part also takes some time to execute, but later I found that more than 90% of the entire execution is spent with playing around with the virtual machine.

The most relevant part is in src/crypto/randomx/vm_compiled.cpp, where the virtual machine is executed. So I slightly modified this part and I extended the code to measure the execution time of compiler.getProgramFunc(). My measurement incorporated 10.000 getProgramFunc() function calls and I got roughly 200 µs for one call on average. So I figured out that it takes 200 µs to initialize and run the virtual machine in the RandomX algorithm on my humble Intel(R) Core(TM) i5-8265U CPU. Here are 1000 calls for your reference:

1000 calls of the getProgramFunc() function and the corresponding execution time in microseconds.

You can see that most of the time the execution time of getProgramFunc() fluctuates around 200 µs, but sometimes it goes as high as 650 µs. The reason for this is unclear for me and I need to investigate the code more to understand what’s happening here.

If we go back to the randomx.cpp file, we can see that the VM is executed 8 times to obtain one hash, therefore if one only considers the required time to execute the VM 1 hash is generated in every 1200 µs on my CPU. In other words, my hashrate should be somewhere around 833 hashes per second. Well, a little bit less, because I haven’t considered the rest of the code, but clearly the getProgramFunc() call is responsible for the majority of the execution time. If you want to optimize your Monero miner, you should look into that part of the code. That’s it for today. Stay tuned for the next post. You can reach me on Whatsapp if you want to talk to me about cryptocurrency mining: +36 30 8316972.

Interesting entries


Mining ravencoin and farming chia on the same machine


What is my ROI on my chia farm investment?


Russian miners are already testing the Nvidia CMP 30HX chip for mining


Technical details and the ROI of Chia Network Farming


Investigating monero mining on a notebook