OpenHFT / Java-Thread-Affinity

Bind a java thread to a given core
http://chronicle.software/products/thread-affinity/
Apache License 2.0
1.78k stars 361 forks source link

Can't lock to CPU 0 #90

Closed nicktindall closed 2 years ago

nicktindall commented 2 years ago

I understand this is probably not something you'd do in the real world, but the code has baked into it the inability to lock to core 0.

We're attempting to write a core-to-core latency test and we're unable to get a number for any pair involving zero.

I'm not sure if the reason for disallowing it is because it's not recommended, or there's another good reason?

nicktindall commented 2 years ago

Some places where the limitation is baked in:

https://github.com/OpenHFT/Java-Thread-Affinity/blob/82dc0bb50ee729a135798977c07100a1e80fcab3/affinity/src/main/java/net/openhft/affinity/AffinityLock.java#L125-L126

https://github.com/OpenHFT/Java-Thread-Affinity/blob/82dc0bb50ee729a135798977c07100a1e80fcab3/affinity/src/main/java/net/openhft/affinity/AffinityLock.java#L276-L279

https://github.com/OpenHFT/Java-Thread-Affinity/blob/82dc0bb50ee729a135798977c07100a1e80fcab3/affinity/src/main/java/net/openhft/affinity/LockInventory.java#L123

nicktindall commented 2 years ago

It feels like we should let net.openhft.affinity.AffinityLock#RESERVED_AFFINITY drive whether a core is reservable exclusively, so we can remove the core-0 restriction more easily if we want to?

JerryShea commented 2 years ago

@peter-k-lawrey is of the opinion that we should not allow core 0 to be isolated as the kernel is likely to be running there