Patch: Integrate async-profiler
Jason Zaugg
jzaugg at gmail.com
Tue Aug 4 09:15:30 UTC 2020
On Tue, 4 Aug 2020 at 14:40, Aleksey Shipilev <shade at redhat.com> wrote:
>
> On 8/4/20 1:42 AM, Jason Zaugg wrote:
> >> If you are fine with it, I can push the entire thing at once.
> >
> > Yes please.
>
> Pushed:
> http://hg.openjdk.java.net/code-tools/jmh/rev/50b5cdf9c528
I found two minor issues in my patch.
AsyncProfiler.filterThread0 is not bound to the native implementation because I
neglected to include the native method declaration for getSamples and
the bulk JVMTI operation,
RegisterNatives, bails out after the first missing method.
I also realised that I incorrectly documented the filterThread API.
null represents the
current thread, not a wildcard for all threads.
diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java
b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java
index 66f572a8..e991207e 100644
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java
@@ -488,12 +488,11 @@ public final class AsyncProfiler implements
ExternalProfiler, InternalProfiler {
* Enable or disable profile collection for threads.
*
* @param thread The thread to enable or disable.
- * <code>null</code> is a wildcard.
+ * <code>null</code> indicates the current thread.
* @param enable Whether to enable or disable.
*/
public void filterThread(Thread thread, boolean enable) {
if (thread == null) {
- // All threads.
filterThread0(null, enable);
} else {
synchronized (thread) {
@@ -512,6 +511,8 @@ public final class AsyncProfiler implements
ExternalProfiler, InternalProfiler {
private native String execute0(String command) throws
IllegalArgumentException, IOException;
+ private native long getSamples();
+
private native void filterThread0(Thread thread, boolean enable);
}
}
I have also proposed a change [1] to the native method registration in
async-profiler
that would avoid the tight coupling.
-jason
[1] https://github.com/jvm-profiling-tools/async-profiler/pull/337
More information about the jmh-dev
mailing list