30% increase in CPU mining hash rate by enabling Huge Pages

Tomas Savenas
3 min readMar 5, 2019

--

After recent Monero network upgrade [4] I updated write-up at 2019–12–05 Also. Right now I see an increase more than 55% by enabling Huge Pages. RandomX algorithm is CPU friendly now.

I use “XMRig 5.0.1” software and HP G8 server with two Intel(R) Xeon(R) CPUs E5–2620, with 30MB of L3 cache to mine Monero (XMR) on Ubuntu [1].

I was getting around 1770 H/s. within messege “rx -- allocated 4416 MB huge pages 0% 0/2208” and “cpu READY threads 12/12 (12) huge pages 0% 0/12 memory”. After doing reseach on Google I found out that this could be fixed by increasing “Huge Pages”.

net  use pool 127.0.0.1:3333  
net new job from 127.0.0.1:3333 diff 480045 algo rx/0 height 1982292
rx init datasets algo rx/0 (24 threads) seed 435333dc1dc4a930...
rx #0 allocated 2080 MB huge pages 0% (17 ms)
rx #1 allocated 2080 MB huge pages 0% (17 ms)
rx #0 allocated 256 MB huge pages 0% +JIT (0 ms)
rx -- allocated 4416 MB huge pages 0% 0/2208 (17 ms)
rx #0 dataset ready (5027 ms)
rx #1 dataset ready (2965 ms)
cpu use profile rx (12 threads) scratchpad 2048 KB
cpu READY threads 12/12 (12) huge pages 0% 0/12 memory 24576 KB (7 ms)
speed 10s/60s/15m n/a n/a n/a H/s max n/a H/s
net new job from 127.0.0.1:3333 diff 480045 algo rx/0 height 1982292
speed 10s/60s/15m 1773.7 n/a n/a H/s max 1773.8 H/s
speed 10s/60s/15m 1773.7 n/a n/a H/s max 1774.6 H/s

My goal is to employ 100% of my hardware for the mining operation. So I increased values acordingly.

Linux

The value of Huge Pages configuration depends on how many threads are being used by the program. I set x pages in the system kernel configuration. [5]

sudo sysctl -w vm.nr_hugepages=$(nproc) 

The command output shows that “Huge Pages” has changed. I run “XMRig” right after, and I see the results. Run Application with sudo rights

sudo ~/xmrig/build/xmrig

Output

net  use pool 127.0.0.1:3333
net new job from 127.0.0.1:3333 diff 480045 algo rx/0 height 1982292
rx init datasets algo rx/0 (24 threads) seed 435333dc1dc4a930...
rx #0 allocated 2080 MB huge pages 100% (513 ms)
rx #1 allocated 2080 MB huge pages 100% (1021 ms)
rx #0 allocated 256 MB huge pages 100% +JIT (69 ms)
rx -- allocated 4416 MB huge pages 100% 2208/2208 (1090 ms)
rx #0 dataset ready (5264 ms)
rx #1 dataset ready (1291 ms)
cpu use profile rx (12 threads) scratchpad 2048 KB
cpu READY threads 12/12 (12) huge pages 100% 12/12 memory 24576 KB (11 ms)
speed 10s/60s/15m n/a n/a n/a H/s max n/a H/s
net new job from 127.0.0.1:3333 diff 480045 algo rx/0 height 1982292
speed 10s/60s/15m 3201.7 n/a n/a H/s max 3202.1 H/s
speed 10s/60s/15m 3201.6 n/a n/a H/s max 3202.1 H/s

Results got increased by more than 55%. Unfortunately, after a system reboot, the change is reset. For the static configuration I need to update kernel configuration file.

sudo bash -c "echo vm.nr_hugepages=$(nproc) >> /etc/sysctl.conf"

Windows

On Group Policy console (gpedit.msc) I made changes on “Lock pages in memory.” by adding a group of users which are allowed to use Huge Pages and then logged out of current Windows session for changes take effect.

Local Computer Policy > Computer Configuration > Windows Settings > Security Settings > Local Policies > User Rights Assignment > Lock pages in memory
Photo by Martin Reisch on Unsplash

Reference

#1 https://medium.com/@tomas_savenas/xmrig-on-ubuntu-18-04-72fc3b688c93
#2 https://www.kernel.org/doc/html/latest/admin-guide/mm/index.html
#3 https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html
#4 https://web.getmonero.org/2019/10/01/announcement-release-0-15.html
#5 https://xmrig.com/docs/miner/hugepages

--

--

Tomas Savenas

Kibernetinio saugumo entuziastas; Aktyviausias Lietuvis TryHackMe platformoje; Inovacijų valdymo ir Antreprenerystės Magistrantas @ KTU