In This Section
Overview
To achieve the lowest possible latency and best throughput with minimal jitter, the platform supports the ability to pin critical threads to individual cpu cores.
Setting CPU Affinity Masks
Configuration of affinities in X The affinity string can either be a long that represents a mask of logical cpu or a square bracket enclosed comma separated list enumerating the logical cpus to which to a thread should be affinitized.
Examples:
- "0" no affinity specified
- "[]" no affinity specified
- "1" specifies logical cpu 0
- "[0]" specifies logical cpu 0
- "4" specifies logical cpu 2
- "[2]" list specifying logical cpu 2
- "6" mask specifying logical cpu 1 and 2
- "4294967296" specifies logical cpu 32
- "[32]" specifies logical cpu 32
- "[1,2]" list specifying logical cpu 1 and 2
Troubleshooting
On linux, invoking the top `top` command and pressing 1 to ensure that they don’t see spinning cores outside of the masks that they have configured. To avoid the following pitfalls:
- Having two threads spinning on the same coreId will make performance worse (either same coreId but different threadId or worse on the same codeId/threadId
- Having some other non X process spinning on one of the coreIds that you’ve affinitized to.
- Affinitizing across multiple socketIds (which are on different numa nodes can make performance worse).
- You will be limited in your max heap to the amount of physical memory in that processor bank of the NUMA node to which you are pinning.
Some practices:
- Before launching validate that there aren’t other processes running that are spinning on a core to which you are affinitizing.
- Check what other processes on the host will use busy spinning and find out the cores they will use.
- In Linux, the OS often uses Core 0 for some of its tasks, so it better to avoid this core if possible.