Monero / Mining
Getting Started with P2Pool: How to Mine Monero
Learn how to mine Monero with P2Pool and XMRig on Linux, using your own node or Monero Love's remote node. Check shares and understand mining payouts.
Monero / Mining / P2Pool
Connect XMRig to P2Pool on Linux, verify huge-page allocation, and benchmark RandomX thread counts to measure hashrate and efficiency.

Start with one accepted share. It confirms that XMRig can do work for P2Pool and submit a valid result. Once that works, change one setting at a time and measure its effect on hashrate.
This walkthrough assumes a Linux x86-64 mining host and a synced P2Pool node. If you still need to set up monerod and P2Pool, follow the upstream Linux setup or our P2Pool setup guide first.
You can download XMRig from the official releases or compile it below. If you download a binary archive, check its SHA-256 hash against the release checksums before extracting it. Run the mining commands from the directory containing your xmrig binary.
On Ubuntu x86-64, install the compiler, CMake and the development packages for libuv, OpenSSL and hwloc. For other distributions, use the package names in XMRig's platform build guides. XMRig Ubuntu build instructions
sudo apt update
sudo apt install git build-essential cmake libuv1-dev libssl-dev libhwloc-dev
Build as your regular user. This example checks out the v6.27.0 release tag. To use another release, replace the tag with the version you want to build.
git clone --depth 1 --branch v6.27.0 https://github.com/xmrig/xmrig.git
cd xmrig
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_OPENCL=OFF -DWITH_CUDA=OFF
cmake --build build --parallel 2
cd build
./xmrig --version
The CMake flags disable the OpenCL and CUDA GPU backends. RandomX CPU mining and its built-in benchmark are enabled by default. If the compiler runs out of memory, retry the build with --parallel 1. Check that ./xmrig --version prints the release you selected, then stay in the build directory for the next command.
If both programs run on the same machine, start XMRig as your regular user:
./xmrig -o 127.0.0.1:3333
Port 3333 is P2Pool's default Stratum listener. If you mine from another machine, replace 127.0.0.1 with the private address of your P2Pool host. P2Pool must listen on that address, and the miner must be able to reach the port. Set your payout address on P2Pool with --wallet. Every miner connected to that instance works for the address configured there.
Watch for new job, followed by the RandomX dataset initialization and the CPU threads becoming ready. An accepted line means P2Pool accepted a result at the miner's assigned difficulty. A sidechain share has a higher target difficulty. Payouts depend on having eligible work in the payout window when P2Pool finds a Monero block. You can see plenty of accepted lines before your first payout.
Record the algorithm shown on the new job line and the worker count XMRig selected. Stop the miner with Ctrl+C before running a benchmark so the two processes don't compete for the same cores.
For a job displaying rx/0, run:
./xmrig --bench=1M -a rx/0
If your job shows another variant, substitute that exact algorithm in every comparison. This offline test computes one million hashes and checks the result. Record the elapsed time and confirm the checksum passes. A shorter time for the same work means a faster configuration. If the checksum fails, return CPU and memory tuning to stock settings and repeat before trusting the speed.
RandomX repeatedly accesses a dataset larger than the CPU cache. Larger memory pages let the CPU cover more of that dataset with each cached address translation. First check the XMRig startup log. If the dataset and CPU workers both report huge pages 100%, you already have full coverage. Keep that run as your baseline.

For partial or zero coverage, stop XMRig and inspect the host:
lscpu | grep -E 'Socket|NUMA node'
grep -E 'MemAvailable|HugePages_|Hugepagesize' /proc/meminfo
sysctl vm.nr_hugepages
Here's a specific case: a dedicated miner with one NUMA node, Hugepagesize: 2048 kB, and no existing reservation. XMRig recommends 1,280 pages as a starting point. That sets aside 2.5 GiB of RAM. Check that the machine can spare it, especially if it also runs monerod.
sudo sysctl -w vm.nr_hugepages=1280
grep -E 'HugePages_Total|HugePages_Free|Hugepagesize' /proc/meminfo
./xmrig -o 127.0.0.1:3333
The sysctl sets the total pool size. On a shared host, account for pages already used by other services before choosing a total. On a multi-node host, check the allocation on each NUMA node. Even if the host has enough pages in total, one node may be short.
Read the two allocation lines in XMRig again. If Linux reserved fewer pages than requested, memory fragmentation can be the reason. Reserving pages early at boot can help. If the pages are free but the miner still cannot allocate them, check the mining user's access to HugeTLB pages and, if you run XMRig as a service, its memory-lock limit. Once the dataset and workers show full coverage, stop the miner and repeat the same benchmark with the same worker count.
The runtime change lasts until reboot. If the benchmark improves, save vm.nr_hugepages = 1280 in /etc/sysctl.d/80-xmrig-hugepages.conf on a systemd-based host. Use the total you tested. To undo the change, stop the miner, remove that setting, and restore the previous sysctl value. XMRig huge-page guide · Linux HugeTLB documentation
Start with XMRig's automatic selection. RandomX workers compete for cache and memory bandwidth. For rx/0, XMRig gives a rule of thumb of 256 KiB of L2 and 2 MiB of L3 per mining thread. On a CPU with separate cache domains, check how much cache the cores in each group share.
Suppose auto-selection gives you 16 workers. With the live miner stopped and huge-page coverage held constant, compare auto against 14 workers:
./xmrig --bench=1M -a rx/0
./xmrig --bench=1M -a rx/0 -t 14
Use counts appropriate to your CPU and confirm the worker count at startup. Repeat each configuration three times under similar load and compare the middle result. Then run the better candidate against P2Pool for at least 30 minutes. Read the 15-minute hashrate after the CPU warms up, and record wall power if you have a meter.
At 12,000 H/s and 150 W, a miner gets 80 H/s per watt. A 14-thread run at 11,600 H/s and 125 W gives 92.8 H/s per watt. In that example, giving up 400 H/s saves 25 W and leaves more CPU time for other work. Use your own readings to decide which tradeoff fits the machine. RandomX optimization guide · XMRig benchmark documentation
Once ordinary huge pages reach 100%, Linux miners can try 1 GiB pages for the RandomX dataset. XMRig estimates a 1% to 3% hashrate gain, depending on the CPU. Budget three 1 GiB pages per mining NUMA node, plus memory for the workers and the rest of the system.
On supported hardware, use the scripts/enable_1gb_pages.sh helper from the matching XMRig source release. Inspect its reservations before applying it to a shared host. Once the pages are available, repeat your benchmark with the same worker count and one extra flag:
./xmrig --bench=1M -a rx/0 --randomx-1gb-pages
Check the dataset initialization line for actual 1 GiB page use. The startup banner can report CPU support even when the allocation falls back. If repeat runs show a worthwhile gain, enable "1gb-pages": true inside the randomx object of your XMRig configuration. If the results overlap your earlier runs, keep the simpler configuration and release the extra reservation.
| What you see | What to check |
|---|---|
Connection refused on 3333 |
On the P2Pool host, run ss -ltn | grep ':3333'. Check the listening address against the address in XMRig's -o option. |
| Full huge-page coverage but unexpectedly low H/s | Compare the algorithm, worker count, and CPU clock under sustained load. Check the startup log for MSR tuning status and keep that status consistent across trials. |
| Good initial speed, then a steady decline | Watch CPU temperature, frequency, and wall power through the warm-up period. Repeat with fewer threads to see whether sustained speed improves. |
| Fast benchmark with a failed checksum | Return CPU and RAM to stock settings and rerun the same test. A correct checksum is part of a usable result. |
| Accepted work, still waiting for XMR | Check P2Pool's status, your configured payout address, and whether you found a sidechain share that was in the payout window when the pool found a block. |
Save the final worker count, huge-page allocation, 15-minute H/s, and wall watts alongside your config. Compare those readings after an XMRig upgrade or hardware change.