-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8368159: Significant performance overhead when started with jdwp agent and unattached debugger #27403
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
Conversation
…t and unattached debugger
|
👋 Welcome back sspitsyn! A progress list of the required criteria for merging this PR into |
|
@sspitsyn This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 193 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
|
|
||
| static void invalidate_jvmti_stack(JavaThread* thread) { | ||
| if (thread->is_interp_only_mode()) { | ||
| if (JvmtiExport::can_post_frame_pop() || thread->is_interp_only_mode()) { |
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.
Can you please explain why this change is required? Doesn't 'invalidate_cur_stack_depth' make sense only when interp_only mode is enabled for the threads only?
It is invalidated once thread switched to interp only.
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.
It seems odd to me that a method called invalidate_jvmti_stack() sometimes doesn't invalidate the stack. Even before this change it was not invalidating unless it was in interp_only mode, which also seems odd. If the cached value is not used for compiled frames, why bother with the interp_only check?
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.
Can you please explain why this change is required? Doesn't 'invalidate_cur_stack_depth' make sense only when interp_only mode is enabled for the threads only?
This is a right question to ask, thanks. I agree this confusing. The issue is with the pure continuations which are executed not in a context of a virtual thread. Without this check the following test is stably failed:
test/hotspot/jtreg/serviceability/jvmti/vthread/ContStackDepthTest
I'm currently kind of puzzled on how to make this check better. I may need to look at this test more time to make sure it is fully correct.
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.
It seems odd to me that a method called invalidate_jvmti_stack() sometimes doesn't invalidate the stack. Even before this change it was not invalidating unless it was in interp_only mode, which also seems odd. If the cached value is not used for compiled frames, why bother with the interp_only check?
I can rename this function to cond_ invalidate_jvmti_stack() if you want. The interp_only check is needed for optimization to avoid a performance overhead of current stack depth invalidation.
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.
I was thinking a lot on how to get rid of this current stack depth recalculation mechanism used in interp_only mode but have not come with a good approach yet. We have a constant trouble from this mechanism needed for debugger optimization purposes.
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 interp_only check is needed for optimization to avoid a performance overhead of current stack depth invalidation.
But if we are not in interp_only mode isn't it already invalidated?
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.
But if we are not in interp_only mode isn't it already invalidated?
It does not need to be invalidated if not in interp_only mode as it should not be used there or has to be explicitly invalidated exactly where it is needed (the frame pops cleaning code for plain Continuations). The issue I see is only with the test test/hotspot/jtreg/serviceability/jvmti/vthread/ContStackDepthTest which is for plain Continuations. Otherwise, the invalidate_jvmti_stack() would not be needed. It plays as a workaround to make this test to pass. It seems there is a bug related to plain Continuations lurking somewhere.
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.
My point is we could just unconditionally invalidate. It would do no harm. It would not be invalidating a curr stack depth that could later be used.
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.
Okay, thanks! I'll make it unconditional. I do not see any performance degradation with that. Also, it will keep the test/hotspot/jtreg/serviceability/jvmti/vthread/ContStackDepthTest test passed.
|
Chris and Leonid, thank you for review! |
|
/integrate |
|
Going to push as commit 17244c6.
Your commit was automatically rebased without conflicts. |
This update removes a significant performance overhead when an application running millions of virtual threads is started with the JDWP agent but debugger has not been attached. The overhead is 4X-6X slowdown.
The tested app normally (without debug agent) takes around 3+ seconds. With debug agent enabled it takes 14 seconds and more. The performance overhead is caused by the
jvmti_yield_cleanup()recursively callingJvmtiExport::continuation_yield_cleanup(). The reason of this overhead is because the functionJvmtiExport::can_post_frame_pop()is used to identify a need for the JVMTI cleanup which is not precise and triggers unneeded work when debugger has not been attached yet. The fix is to trigger the JVMTI cleanup with new function:bool JvmtiExport::has_frame_pops(JavaThread* thread).Testing:
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27403/head:pull/27403$ git checkout pull/27403Update a local copy of the PR:
$ git checkout pull/27403$ git pull https://git.openjdk.org/jdk.git pull/27403/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27403View PR using the GUI difftool:
$ git pr show -t 27403Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27403.diff
Using Webrev
Link to Webrev Comment