-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8369736 - Add management interface for AOT cache creation #28010
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
base: master
Are you sure you want to change the base?
Conversation
|
👋 Welcome back macarte! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java
Outdated
Show resolved
Hide resolved
src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java
Outdated
Show resolved
Hide resolved
src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java
Outdated
Show resolved
Hide resolved
test/hotspot/jtreg/runtime/cds/appcds/aotCache/HotSpotAOTCacheMXBeanTest.java
Outdated
Show resolved
Hide resolved
src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java
Outdated
Show resolved
Hide resolved
src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java
Outdated
Show resolved
Hide resolved
src/jdk.management/share/classes/jdk/management/HotSpotAOTCacheMXBean.java
Outdated
Show resolved
Hide resolved
…eMXBean.java Co-authored-by: Dan Heidinga <[email protected]>
…eMXBean.java Co-authored-by: Dan Heidinga <[email protected]>
|
|
| * } | ||
| * </pre></blockquote> | ||
| * | ||
| * @return {@code true} if a recording was in progress and has been ended successfully; {@code false} otherwise. |
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.
Someone is bound to ask what happens if the "endRecording" operation is performed concurrently and there is recording in progress. Does one or all return true? I don't think it matters, the bigger issue here is that returning false means the recording has already ended or it failed. If it failed, why did it fail? I realize the intention is to add some properties and further operations to this MXBean but I think it would be good to think through if starting with a boolean returning operation is going to be problematic in the future.
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 see a couple of cases for when endRecording is called:
-
Within the same process to generate a cache - given the api will only return
trueto one caller, that caller is the only one who can be responsible for taking further action (copying the cache somewhere, etc). Already ended or failed makes no difference operationally. -
From a monitoring process - again only the successful case matters. All failures (already ended or failed) are indistinguishable. No further action can be taken by the observer. It's only the success case that matters
|
Can this be done using a diagnostic command, e.g. AOT.stop? It would allow the recording to be stopped from jcmd and the DiagnosticCommandMBean, without the need for a separate MXBean. |
Thank you for the suggestion To answer your first question, we do have a diagnostic command (AOT.end_recording) and it would precede the AOT MXBean into mainline and its PR is here: #27965 The longer goal for this MXBean is to provide additional methods that would aid in monitoring (isRecording, currentRecordingLength etc.), however we decided to reduce the scope of the MXBean for main line while we continue to test the monitoring functionality in leyden/premain Historically the diagnostic command came after the MXBean in leyden/premain, however I decided to implement the diagnostic command with the necessary JVM hooks first to simplify review So technically we could delay this PR and still have the required functionality in mainline, I'd like to hear from the other reviewers on this matter |
Ah, I didn't know that. (I don’t have a strong opinion on this, but for consistency you might want the jcmd commands for AOT recording to use the same naming convention for starting, stopping, and checking the status of a recording as JFR: JFR.start, JFR.stop, JFR.check, JFR.dump and JFR.configure, where applicable. Initially, we had start_recording, but we later shortened it to start to avoid unnecessary typing)
Ok. |
| * <p>For more information about creating and using the AOT artifacts, and detailed | ||
| * specification of the corresponding JVM command-line options, please refer | ||
| * to https://openjdk.org/jeps/483 and https://openjdk.org/jeps/514. | ||
| * |
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.
Please don't use bare URLs. Change these to
... please refer to JEPs <a href="https://openjdk.org/jeps/483">483</a> and
<a href="https://openjdk.org/jeps/514">514</a>.
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.
fixed
…ke AOT.end_recording" Commit was intended for parent branch (that this branch is based on) This reverts commit bff7cb7.
|
I went through the plumbing to check the registration with the platform MBeanServer and everything looks okay (and consistent with how the other JDK-specific management interfaces are setup and registered). |
| * @return {@code true} if a recording was in progress and has been ended | ||
| * successfully; {@code false} otherwise. | ||
| */ | ||
| public boolean endRecording(); |
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.
Minor nit is that we usually use 4-space rather than 2-space indent in the java sources. You might want to check the /** .. */ comments in a few of the files as they are misaligned in a few places.
| * @summary Sanity test for HotSpotAOTCache MXBean | ||
| * @requires vm.cds.write.archived.java.heap | ||
| * @library /test/jdk/lib/testlibrary /test/lib | ||
| * /test/hotspot/jtreg/runtime/cds/appcds/aotCache/test-classes |
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.
Is test-classes used?
| import jdk.test.lib.helpers.ClassFileInstaller; | ||
| import jdk.test.lib.process.OutputAnalyzer; | ||
|
|
||
| public class HotSpotAOTCacheMXBeanTest { |
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.
In addition to testing the endRecording operation, we also need to test both the direct and indirect access to the MXBean. The test currently obtains a proxy with newPlatformMXBeanProxy (good) but the direct access with ManagementFactory.getPlatformMXBean is not tested right now.
Another thing to test is that getObjectName returns the expected object name.
| out.shouldContain("Failed to stop recording"); | ||
| } | ||
| out.shouldNotContain("HotSpotAOTCacheMXBean is not available"); | ||
| out.shouldNotContain("IOException occurred!"); |
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.
Have you considering have the child terminate with an exception so the exit status is non-0. If you get a success status then the output should have the expected strings. A non-0 would failure, and the test fails.
src/jdk.management/share/classes/com/sun/management/internal/HotSpotAOTCacheImpl.java
Outdated
Show resolved
Hide resolved
| public Map<String, HotSpotAOTCacheMXBean> nameToMBeanMap() { | ||
| HotSpotAOTCacheMXBean impl = this.impl; | ||
| if (impl == null) { | ||
| this.impl = impl = new HotSpotAOTCacheImpl(ManagementFactoryHelper.getVMManagement()); |
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.
This assignment is unusual. Are we trying to avoid a synchronized block? Other nameToMBeanMap() methods are like:
return Collections.singletonMap(ManagementFactory.MEMORY_MXBEAN_NAME, ManagementFactoryHelper.getMemoryMXBean());
..where the ManagementFactoryHelper.getMemoryMXBean() method is synchronized and creates the impl if needed.
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 don't see a correctness issue with this. Maybe in the future we will be able to use LazyConstant here.
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.
Sure, I'm just pointing out that we have a load of existing nameToMBeanMap() methods that do things differently.
OK I now see this one is doing what the new VirtualThreadSchedulerMXBean did.
The others are different: commonly the nameToMBeanMap() methods in PlatformMBeanProviderImpl.java are synchronized, or they call a getXXMXBean() method which is synchronized.
Maybe these old methods don't need to be synchronized, if this all gets done at startup in PlatformMBeanProviderImpl init(), the mbeans will always be created once.
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 older code pre-dates unmodifiable maps (JEP 269), it could be modernized some time.
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.
Thanks yes would be good to do that some time.
It looks like an effort with the older accesors to enforce that they are singletons. That may not be important for all the mxbeans.
|
The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork: git checkout JDK-8369736
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push |
|
@macarte this pull request can not be integrated into git checkout JDK-8369736
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
Add jdk.management.AOTCacheMXBean. The interface provides a single action that when called will cause any hosted JVM currently recording AOT information will stop recording. Existing functionality is preserved: when stopped the JVM will create the required artifacts based on the execution mode. Conveniently as the application running on the JVM has not stopped (as was previously the only way to stop recording), the application will resume execution after the artifacts have been generated.
The interface will return TRUE if a recording was successfully stopped, in all other cases (not recording etc.) will return FALSE
It follows that invoking the action on a JVM that is recording, twice in succession, should (baring internal errors) produce the following two responses:
TRUE
FALSE
Passes tier1 on linux (x64) and windows (x64)
Progress
Issues
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28010/head:pull/28010$ git checkout pull/28010Update a local copy of the PR:
$ git checkout pull/28010$ git pull https://git.openjdk.org/jdk.git pull/28010/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28010View PR using the GUI difftool:
$ git pr show -t 28010Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28010.diff
Using Webrev
Link to Webrev Comment