How do I pin XMRig threads to specific CPU cores?
You can pin XMRig’s mining threads to specific CPU cores by listing their CPU numbers in its config.json file. This is called CPU affinity: it tells your operating system which processors each mining thread should use.
Find the right CPU numbers
The numbers you enter are logical CPU IDs, starting at 0. A logical CPU is a processor slot your operating system can schedule work on. It is not always a separate physical core.
With Intel Hyper-Threading or AMD’s simultaneous multithreading, one physical core can appear as two logical CPUs. Pinning two mining threads to those two slots still makes them share one physical core.
Before choosing IDs:
- Linux: Run
lscpu -e=CPU,CORE,SOCKET. CPU IDs with the same core and socket numbers share a physical core. - Windows: Microsoft’s Coreinfo utility can show the relationship between logical processors and physical cores.
Do not assume that IDs 0, 2, 4, 6 represent four separate physical cores. Numbering varies between systems.
Set thread affinity in XMRig’s configuration
Stop XMRig and back up your config.json. Find its existing "cpu" section and locate the "rx" thread profile. This controls threads for RandomX, Monero’s mining algorithm—the calculation your CPU performs to mine.
For example, this configuration fragment assigns four mining threads to logical CPUs 0, 2, 4, and 6:
"cpu": {
"enabled": true,
"rx": [0, 2, 4, 6]
}
Merge those settings into your existing CPU section rather than adding a second "cpu" section. Keep your other settings intact.
Each array entry represents one mining thread:
[0, 2]starts two threads, pinned to those CPU IDs.[1, 3, 5]starts three pinned threads.[-1, -1]starts two threads without assigning specific CPUs.
If your configuration also contains an "rx/0" profile, check it too. That more specific profile can take precedence for Monero’s RandomX variant.
Save the file and restart XMRig using that configuration:
xmrig --config=config.json
Understand the command-line alternative
XMRig also offers --cpu-affinity, which takes a bitmask: a number whose binary digits mark the allowed logical CPUs.
For example:
xmrig --cpu-affinity=0x55
The hexadecimal mask 0x55 selects logical CPUs 0, 2, 4, and 6.
This option is useful with automatic thread configuration. However, it does not itself specify how many mining threads you want, and an existing explicit thread profile can affect the result. For a clear, repeatable thread-to-CPU mapping, use the "rx" array.
Check whether pinning actually helps
Restart XMRig and check its startup output for the selected CPU profile and thread count. Compare its reported mining speed over several minutes before and after your change.
Start with one thread per physical core. RandomX generally needs about 2 MB of L3 cache per mining thread—L3 cache is fast memory shared within your CPU—so filling every logical CPU may reduce performance.
Watch temperatures and keep some processing capacity available if you use the computer for other work. Pinning does not reserve those cores exclusively; other programs can still run on them.
The bottom line
For predictable pinning, map your CPU IDs, edit XMRig’s "rx" array, and restart. Test the result: the best arrangement is the one that improves mining speed without making your computer too hot or unresponsive.
