-
Notifications
You must be signed in to change notification settings - Fork 721
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
Update jvmtiGetThreadGroupChildren for java 19 #15539
Update jvmtiGetThreadGroupChildren for java 19 #15539
Conversation
cab5162
to
c41c9d9
Compare
Test in linked issue passes with these changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message/description should include few lines on how the threads
and groups
arrays are created for Java 19+. It will make it easier to follow the source code.
} while ((targetThread = targetThread->linkNext) != vm->mainThread); | ||
|
||
*rv_thread_count = nLiveThreads; | ||
*rv_threads = threads; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On return, the
jthread*
points to a newly allocated array ofsize*thread_count_ptr
threads
array is of size totalThreadCount
which is greater than nLiveThreads
. Is it fine to return an array of larger size? We allow this in our current implementation; the answer may be "yes".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We return the actual number of threads in the array so it probably is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of allocated memory will be unused if the filter excludes a lot of threads. Filter: include only platform threads which match the thread_group.
*rv_thread_count = nLiveThreads; | ||
*rv_threads = threads; | ||
*rv_group_count = nGroupsTotal; | ||
*rv_groups = groups; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On return, the
jthreadGroup*
points to a newly allocated array ofsize*group_count_ptr
groups
array is of size nGroups + nWeaks
, which is greater than nGroupsTotal
. Is it fine to return an array of larger size? We allow this in our current implementation; the answer may be "yes".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of allocated memory will be unused if a lot of weak references are null.
5f21af4
to
7460947
Compare
@EricYangIBM The commits can be squashed. @tajila These changes should work fine. But, still doubtful about the memory allocated for |
7460947
to
7150903
Compare
This is not going to return vthreads correct? If so, then I dont think returning a potentially larger buffer is a big deal as platform threads arent created as frequently |
It could be an optimization that is added later |
Vthreads will not be returned. See ref below. @EricYangIBM Can you add a comment in code and open an issue regarding this optimization for tracking purposes? Ref: https://download.java.net/java/early_access/jdk19/docs/specs/jvmti.html#GetThreadGroupChildren |
50f8122
to
342dc03
Compare
I will open the issue after this PR is merged (to link to the comment) |
LGTM. The commits need to be squashed before the PR builds are launched. |
The ThreadGroup class does not store its threads anymore and child groups are separated into "groups" and "weaks" ThreadGroup arrays. The child ThreadGroups array is populated from the ThreadGroup's "groups" and "weaks" arrays, which are the child ThreadGroups that are strongly and weakly reachable from the parent. The threads array is constructed by iterating over all J9VMThreads and adding the threads that belong in the given ThreadGroup. The returned arrays are constructed while locking on the ThreadGroup object. Fixes: eclipse-openj9#15244 Issue: eclipse-openj9#15183 Signed-off-by: Eric Yang <eric.yang@ibm.com>
342dc03
to
077da24
Compare
Squashed |
jenkins compile win jdk19,jdk17 |
Does not work for me yet. Need to wait for @AdamBrousseau to add me. |
jenkins compile win jdk19,jdk17 |
jenkins test sanity amac jdk19,jdk17 |
These JVMTI changes should only impact the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Opened #15673 for the JIT failure.
Still can't merge the PR. Need to wait for @AdamBrousseau to give the required permissions. |
This is an Eclipse Github team thing. It should be automatic. If it's not working then I would open an Eclipse ticket. |
GetThreadGroupChildren was fixed by eclipse-openj9#15539. The above PR removed the exclude for JDK19. But, the exclude for JDK20 was not removed. Related: eclipse-openj9#15244 Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
The ThreadGroup class does not store its threads anymore and child groups
are separated into "groups" and "weaks" ThreadGroup arrays.
The child ThreadGroups array is populated from the ThreadGroup's "groups"
and "weaks" arrays, which are the child ThreadGroups that are strongly
and weakly reachable from the parent.
The threads array is constructed by iterating over all J9VMThreads and
adding the threads that belong in the given ThreadGroup.
The returned arrays are constructed while locking on the ThreadGroup
object.
Fixes: #15244
Issue: #15183
Signed-off-by: Eric Yang eric.yang@ibm.com