-
Notifications
You must be signed in to change notification settings - Fork 737
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
Thread::getState is a scalability issue #17251
Comments
Potential solution: Add a field in j.l.Thread which will store the current state of the Java thread. It will be atomically updated as the Java thread goes through the various state transitions in native and Java code. With this approach, |
We've talked about this for years - there's no need for an atomic update. Like so many APIs, the return value is momentary, likely to be different a few instructions later. |
In some stress tests I ran, the expense comes mostly from calling into native code and computing the state lazily; not so much from needing to halt the thread. Adding a field (or using an existing unused field) to For the Java 19+ code, In pre-Java 19
|
Updating thread state on transition instead of trying to derive it based on other information seems sensible to me. |
Java -version output
All versions
Summary of problem
The Netty project was using
Thread::getState
on a non-current thread. Due to needing to halt the thread for inspection, there was a scalability issue when using Netty on OpenJ9.They've worked around it by calling
Thread::isAlive
instead for OpenJ9, but this kind of lingering scalability issue may affect others as well.Original issue: netty/netty#13347 (comment)
Workaround: netty/netty#13357
The text was updated successfully, but these errors were encountered: