Patch: Integrate async-profiler

Jason Zaugg jzaugg at gmail.com
Tue Aug 4 10:13:16 UTC 2020


You are too fast! I found a third issue that prevents thread filtering
in wall clock profiling.

We need to enable filtering with a dummy thread (filter=0) when the
profiler starts so that
the subsequent registration of active threads in by user code actually filters.

I also fixed an incorrect parameter description for optThreads.

With all this in place I'm seeing useful output [1] for -prof
async:event=wall;filter=true;output=flamegraph.

-jason

[1] https://github.com/scala/compiler-benchmark/pull/105

# HG changeset patch
# User Jason Zaugg <jzaugg at gmail.com>
# Date 1596535469 -36000
#      Tue Aug 04 20:04:29 2020 +1000
# Branch thread-filter
# Node ID 22e9854589b282e5b86a451e8899b96a650a97f6
# Parent  6e70048e3f4d0a6b5bd0a9c6aaabb4a4cec4a106
Another async-profiler followup for thread filtering

Expose an option to enable thread filtering so that subsequent
programmatic registration of threads actually filters.

diff -r 6e70048e3f4d -r 22e9854589b2
jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java
   Tue Aug 04 11:45:31 2020 +0200
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java
   Tue Aug 04 20:04:29 2020 +1000
@@ -111,9 +111,15 @@
                 "Size of profiler framebuffer")
                 .withRequiredArg().ofType(Long.class).describedAs("bytes");

+        OptionSpec<Boolean> optFilter = parser.accepts("filter",
+                "Enable thread filtering during collection. Useful
for wall clock profiling, " +
+                    " but only if the workload registers the relevant
threads programatically " +
+                    " via
`AsyncProfiler.JavaApi.getInstance().filterThread(thread, enabled)`.")
+
.withRequiredArg().ofType(Boolean.class).defaultsTo(false).describedAs("boolean");
+
         OptionSpec<Boolean> optThreads = parser.accepts("threads",
                 "Profile threads separately")
-                .withRequiredArg().ofType(Boolean.class).describedAs("int");
+                .withRequiredArg().ofType(Boolean.class).describedAs("bool");

         OptionSpec<Boolean> optSimple = parser.accepts("simple",
                 "Simple class names instead of FQN")
@@ -196,6 +202,10 @@
             builder.appendIfTrue(optSig);
             builder.appendIfTrue(optAnn);
             builder.appendIfExists(optFrameBuf);
+            if (optFilter.value(set)) {
+                builder.appendRaw("filter=0");
+            }
+            builder.appendIfExists(optFilter);
             builder.appendMulti(optInclude);
             builder.appendMulti(optExclude);


On Tue, 4 Aug 2020 at 19:48, Aleksey Shipilev <shade at redhat.com> wrote:
>
> On 8/4/20 11:15 AM, Jason Zaugg wrote:
> > 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:
> >> Pushed:
> >>   http://hg.openjdk.java.net/code-tools/jmh/rev/50b5cdf9c528
> >
> > I found two minor issues in my patch.
>
> No big deal:
>   https://hg.openjdk.java.net/code-tools/jmh/rev/6e70048e3f4d
>
> --
> Thanks,
> -Aleksey
>


More information about the jmh-dev mailing list