Thread.getState() very slow
Doug Lea
dl at cs.oswego.edu
Fri Aug 13 16:59:03 UTC 2010
Sorry for the long delay on this...
On 07/15/10 23:43, Mandy Chung wrote:
> I think making Thread.threadStatus a volatile field and using
> JVMTI_JAVA_LANG_THREAD_STATE_MASK to convert Thread.threadStatus to Thread.State
> enum would be a good solution.
>
>
> It'd be great if Doug can do the experiment and evaluate the performance impact.
> If you want me to prototype the jdk change, let me know and I should be able to
> make some time to do it next week.
>
I did an equivalent experiment (of just directly accessing
threadState via Unsafe.getIntVolatile and comparing it to
cached values) and it was about 14X faster. So anything
along these lines would be grat. That said, I decided not
to try to rely on getState in the near term. (Among other
reasons, it does not usually reflect IO blockage.) So this
is off the critical path for now. But someday someone is sure
to run into similar performance issues unless implementation
is improved.
-Doug
More information about the core-libs-dev
mailing list