-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[GR-51654] Add support for JFR jdk.ObjectCount and jdk.ObjectCountAfterGC events. #7433
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
Open
roberttoyonaga
wants to merge
8
commits into
oracle:master
Choose a base branch
from
roberttoyonaga:object-count
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0ad9f8d
data structure and vm op working
roberttoyonaga 4a5c404
event emission
roberttoyonaga 644de03
tests, type repo, sync, periodic events
roberttoyonaga cdc5809
minor feedback items
roberttoyonaga 2c3a381
handle generated classes properly
roberttoyonaga 641d6ba
use NonMovableArrays
roberttoyonaga 52cb765
walk whole heap. Remove old assertion
roberttoyonaga 3b3e77b
remove old files and style
roberttoyonaga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,6 +336,7 @@ | |
], | ||
"requires" : [ | ||
"jdk.management", | ||
"jdk.jfr", | ||
], | ||
"requiresConcealed" : { | ||
"java.base": [ | ||
|
59 changes: 59 additions & 0 deletions
59
...ore.genscavenge/src/com/oracle/svm/core/genscavenge/EveryChunkNativeGCPeriodicEvents.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
package com.oracle.svm.core.genscavenge; | ||
|
||
import com.oracle.svm.core.Uninterruptible; | ||
import com.oracle.svm.core.heap.GCCause; | ||
import com.oracle.svm.core.heap.Heap; | ||
import com.oracle.svm.core.jfr.JfrEvent; | ||
import jdk.jfr.Event; | ||
import jdk.jfr.Name; | ||
import jdk.jfr.Period; | ||
|
||
@Name("EveryChunkPeriodicGCEvents") | ||
@Period(value = "everyChunk") | ||
public class EveryChunkNativeGCPeriodicEvents extends Event { | ||
|
||
public static void emit() { | ||
emitObjectCount(); | ||
} | ||
|
||
private static void emitObjectCount() { | ||
if (shouldEmitObjectCount()) { | ||
Heap.getHeap().getGC().collectCompletely(GCCause.JfrObjectCount); | ||
} | ||
} | ||
|
||
/** | ||
* ShouldEmit will be checked again later. This is merely an optimization to avoid a potentially | ||
* unnecessary GC. | ||
*/ | ||
@Uninterruptible(reason = "Caller of JfrEvent#shouldEmit must be uninterruptible.") | ||
private static boolean shouldEmitObjectCount() { | ||
return JfrEvent.ObjectCount.shouldEmit(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 assertion was failing due to
com.sun.proxy.jdk.proxy1
. I think this assertion is incorrect because its possible we may sometimes need to serialize symbols not in the image heap. This was exposed now since the ObjectCount event causes many more symbols to be required. What do you think?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.
That would be bad, then we would need to change
JfrSymbolRepository
significantly. Do you have a stack trace?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.
If the string is not in the image heap, would it be possible to derive the hash from the symbol string itself rather than from its memory address?
I added an assertion to
JfrTypeRepository.writePackage
. Then withmx native-unittest
: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.
@roberttoyonaga : please try to figure out where the problematic
Package
object is created, for whichpackage.getName()
returns an object that doesn't live in the image heap. I suppose thatPackage
object also doesn't live in the image heap?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 gets created the first time we try to get the package. In this case, that's in
JfrTypeRepository
while we're trying to write out the type data.Class.getPackage()
-->BootLoader.definePackage(Class<?> c)
-->Target_jdk_internal_loader_BootLoader.getDefinedPackage
-->Target_java_lang_Package()
That's correct. It seems like when
DynamicHubInitializer.registerPackage
is called at build time,javaClass.getPackage()
returns null for all packages with namecom.sun.proxy.jdk.proxy1
, preventing the package from being registered. Maybe this is why the package is not in the image heap.Is something wrong with the behavior for handling proxy classes? Otherwise, should we modify the
JfrSymbolRepository
(I can do that in a separate PR)?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 sounds like a difference in behavior between Native Image and HotSpot. If HotSpot directly returns
null
for the package of proxy classes, then Native Image should do the same (i.e., it should not allocate a package at run-time inTarget_jdk_internal_loader_BootLoader.getDefinedPackage
).Please try to implement a smaller reproducer that shows this difference in behavior and open a separate issue for this problem.
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.
Hi @christianhaeubl, I've opened an issue here: #8796
It includes a small reproducer too.