-
Notifications
You must be signed in to change notification settings - Fork 720
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
Investigate removal of locks in java.lang.Thread #20414
Comments
Issue Number: 20414 |
A few of these However, PR 1 states that the crashes occurred due to unexpected/inconsistent state of the
This value may be over estimating the problem slightly since
Which locks were removed for this testing? |
threadRef = NO_REF assigned will happen once, and similarly, the started field is also set once during initialization. A user of these methods will probably invoke them multiple times until the desired result is achieved. A delay in getting the most up-to-date value should not hinder the functionality of these methods. To sum up, removing synchronization in these methods improves perf by reducing lock contention without hindering the functionality. Related: eclipse-openj9#20414 Signed-off-by: Babneet Singh <[email protected]>
In JDK17, contention is seen in the following code path:
This contention should be fixed by #20415. |
In JDK21, contention is seen in a different code path:
A synchronized block was added in
|
threadRef = NO_REF assignment will happen once, and similarly, the started field is also set once during initialization. A user of these methods will probably invoke them multiple times until the desired result is achieved. A delay in getting the most up-to-date value should not hinder the functionality of these methods. To sum up, removing synchronization in these methods improves perf by reducing lock contention without hindering the functionality. Related: eclipse-openj9#20414 Signed-off-by: Babneet Singh <[email protected]>
threadRef = NO_REF assignment will happen once, and similarly, the started field is also set once during initialization. A user of these methods will probably invoke them multiple times until the desired result is achieved. A delay in getting the most up-to-date value should not hinder the functionality of these methods. To sum up, removing synchronization in these methods improves perf by reducing lock contention without hindering the functionality. Reference to PR 1FJMO7Q has been removed and a comment related to ThreadGroup has been updated since the code seems to have evolved since the comments were written. Related: eclipse-openj9#20414 Signed-off-by: Babneet Singh <[email protected]>
threadRef = NO_REF assignment will happen once, and similarly, the started field is also set once during initialization. A user of these methods will probably invoke them multiple times until the desired result is achieved. A delay in getting the most up-to-date value should not hinder the functionality of these methods. To sum up, removing synchronization in these methods improves perf by reducing lock contention without hindering the functionality. Reference to PR 1FJMO7Q has been removed and a comment related to ThreadGroup has been updated since the code seems to have evolved since the comments were written. Related: eclipse-openj9#20414 Signed-off-by: Babneet Singh <[email protected]>
Made threadRef volatile so that the most up-to-date value is seen by all the threads. threadRef = NO_REF assignment will happen once, and similarly, the started field is also set once during initialization. A user of these methods will probably invoke them multiple times until the desired result is achieved. A delay in getting the most up-to-date value should not hinder the functionality of these methods. To sum up, removing synchronization in these methods improves perf by reducing lock contention without hindering the functionality. Reference to PR 1FJMO7Q has been removed and a comment related to ThreadGroup has been updated since the code seems to have evolved since the comments were written. Related: eclipse-openj9#20414 Signed-off-by: Babneet Singh <[email protected]>
I'm not sure as to why we would have had locks around I think we can hoist the reads and writes of |
Lock contention in Thread.getAndClearInterrupt is reduced by acquiring the lock only when the value of the Thread.interrupted field is true. Related: eclipse-openj9/openj9#20414 Signed-off-by: Babneet Singh <[email protected]>
Issue
High lock contention can due to the below locks in j.l.Thread class.
By relaxing locking in some j.l.Thread APIs, 10% perf improvement was observed in a Netty application run through the Quarkus framework.
Goal
There is an opportunity to improve the perf of OpenJ9's j.l.Thread APIs by either removing the lock in some cases or utilizing separate locks for some critical sections. This issue has been opened to initiate a discussion on the best approach to improve perf by not hindering functionality.
Existing case (see #17251): We are improving
Thread.getState
by removing the need of a lock and complex work to evaluate the state.Potential new cases:
isAlive
,isDead
).start
,join
and other key methods. On the other hand, theinterruptLock
should only be used forinterrupt
specific work.setPriority
,setDaemon
).The text was updated successfully, but these errors were encountered: