-
Notifications
You must be signed in to change notification settings - Fork 372
AffinityLock.acquireCore should lock/unlock all cpus ie 2 when hypert… #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tgd
reviewed
May 23, 2025
affinity/src/test/java/net/openhft/affinity/impl/VanillaCpuLayoutPairTest.java
Show resolved
Hide resolved
tgd
reviewed
May 23, 2025
affinity/src/main/java/net/openhft/affinity/lockchecker/LockChecker.java
Show resolved
Hide resolved
tgd
reviewed
May 23, 2025
affinity/src/main/java/net/openhft/affinity/lockchecker/FileLockBasedLockChecker.java
Show resolved
Hide resolved
… identifier on lock failure
…e-fix # Conflicts: # affinity/src/test/java/net/openhft/affinity/AffinityLockTest.java
Java9 fixes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change makes
AffinityLock.acquireCore()
correctly reserve all logicalCPUs that share the same physical core (e.g. both SMT / Hyper-Threads).
It touches the lock inventory, PID-file handling and CPU-layout APIs, plus adds
new verification tests.
✨ Behavioural changes
AffinityLock.acquireCore()
now locks both hyper-threads on the target core, preventing other threads or JVMs from binding to the sibling logical CPU.cpuId2
to track the paired logical CPU.• Hex mask parsing uses
Long.parseUnsignedLong
(fixes > 64-bit masks).•
acquireLock(int)
returns noLock (not exception) when CPU id is out-of-range.•
acquireLock(int[])
silently skips invalid ids with a log warning.int pair(int cpuId)
returns the hyper-thread twin (0 if not HT). Implemented inVanillaCpuLayout
; stubbed inNoCpuLayout
.LockChecker
&FileLockBasedLockChecker
upgraded soobtainLock()
can atomically grab two lock files (cpu
,cpuId2
). PID logging & replace logic updated accordingly.cpuId
and itspair()
. Whole-core acquisition path passes both ids toLockCheck
.🛠️ API surface changes
CpuLayout
– +pair(int cpuId)
LockChecker.obtainLock(int cpu1, int cpu2, String meta)
– supersedes old 2-arg variant (now removed).Internal interfaces only – no public-API break for typical callers.
🧪 Tests
VanillaCpuLayoutPairTest
pair()
mapping on sample i7 & i3 cpuinfo.AffinityLockTest
acquireCore()
reserves all logical CPUs of a core and updates existing expectations to dual-id locks.FileLockLockCheckTest
,LockCheckTest
updateCpu
/replacePid
signatures.Total diff +170 / -47 (mostly tests & lock-plumbing).
✅ Compatibility & Migration
LockChecker.obtainLock()
directly must adopt thenew 3-arg form (very rare outside this repo).