Switch-vov commented on a change in pull request #52:
URL: 
https://github.com/apache/skywalking-data-collect-protocol/pull/52#discussion_r663326410



##########
File path: language-agent/JVMMetric.proto
##########
@@ -85,8 +86,22 @@ enum GCPhrase {
 }
 
 message Thread {
-  int64 liveCount = 1;
-  int64 daemonCount = 2;
-  int64 peakCount = 3;
+    int64 liveCount = 1;
+    int64 daemonCount = 2;
+    int64 peakCount = 3;
+    int64 deadlockedCount = 4;
+    int64 monitorDeadlockedCount = 5;
+    int64 newStateThreadCount = 6;
+    int64 runnableStateThreadCount = 7;
+    int64 blockedStateThreadCount = 8;
+    int64 waitingStateThreadCount = 9;
+    int64 timedWaitingStateThreadCount = 10;
+    int64 terminatedStateThreadCount = 11;

Review comment:
       > There are some issues in the benchmark:
   > 
   > * the fork `value=1` and `warmups=1` are too small IMO.
   > * The result of the tested method 
`ClassProvider.INSTANCE.getClassMetrics()` and 
`ThreadProvider.INSTANCE.getThreadMetrics()` are not consumed, which might be 
optimized into NOOP by JVM.
   > 
   > If this is a critical path and the benchmark result really matters, we 
should redo with 👆 fixed, otherwise this PR also looks good to me.
   
   Increase fork `value` to 5 and `warmups` to 3.
   Use `Blackhole` consume the result.
   
   @kezhenxu94 please review again.
   
   ## ThreadProviderBenchmark
   
   ```java
   package org.apache.skywalking.apm.agent.core.jvm.thread;
   
   import org.openjdk.jmh.annotations.Benchmark;
   import org.openjdk.jmh.annotations.BenchmarkMode;
   import org.openjdk.jmh.annotations.Fork;
   import org.openjdk.jmh.annotations.Mode;
   import org.openjdk.jmh.annotations.OutputTimeUnit;
   import org.openjdk.jmh.infra.Blackhole;
   import org.openjdk.jmh.runner.Runner;
   import org.openjdk.jmh.runner.options.Options;
   import org.openjdk.jmh.runner.options.OptionsBuilder;
   
   import java.util.concurrent.TimeUnit;
   
   public class ThreadProviderBenchmark {
   
       @Benchmark
       @Fork(value = 5, warmups = 3)
       @OutputTimeUnit(TimeUnit.SECONDS)
       @BenchmarkMode(Mode.Throughput)
       public void getThreadMetrics(Blackhole bh) {
           bh.consume(ThreadProvider.INSTANCE.getThreadMetrics());
       }
   
       public static void main(String[] args) throws Exception {
           Options opt = new 
OptionsBuilder().include(ThreadProviderBenchmark.class.getSimpleName())
                   .build();
           new Runner(opt).run();
       }
   
       /**
        * # JMH version: 1.21
        * # VM version: JDK 1.8.0_231, Java HotSpot(TM) 64-Bit Server VM, 
25.231-b11
        * # VM invoker: 
/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/jre/bin/java
        * # VM options: -javaagent:/Users/switch/Library/Application 
Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.7442.40/IntelliJ 
IDEA.app/Contents/lib/idea_rt.jar=52623:/Users/switch/Library/Application 
Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.7442.40/IntelliJ 
IDEA.app/Contents/bin -Dfile.encoding=UTF-8
        * # Warmup: 5 iterations, 10 s each
        * # Measurement: 5 iterations, 10 s each
        * # Timeout: 10 min per iteration
        * # Threads: 1 thread, will synchronize iterations
        * # Benchmark mode: Throughput, ops/time
        * # Benchmark: 
org.apache.skywalking.apm.agent.core.jvm.thread.ThreadProviderBenchmark.getThreadMetrics
        *
        * Benchmark                                  Mode  Cnt       Score      
Error  Units
        * ThreadProviderBenchmark.getThreadMetrics  thrpt   25  247393.607 ± 
2493.640  ops/s
        */
   }
   ```
   
   ## ClassProviderBenchmark
   ```java
   package org.apache.skywalking.apm.agent.core.jvm.clazz;
   
   import org.openjdk.jmh.annotations.Benchmark;
   import org.openjdk.jmh.annotations.BenchmarkMode;
   import org.openjdk.jmh.annotations.Fork;
   import org.openjdk.jmh.annotations.Mode;
   import org.openjdk.jmh.annotations.OutputTimeUnit;
   import org.openjdk.jmh.infra.Blackhole;
   import org.openjdk.jmh.runner.Runner;
   import org.openjdk.jmh.runner.options.Options;
   import org.openjdk.jmh.runner.options.OptionsBuilder;
   
   import java.util.concurrent.TimeUnit;
   
   public class ClassProviderBenchmark {
   
       @Benchmark
       @Fork(value = 5, warmups = 3)
       @OutputTimeUnit(TimeUnit.SECONDS)
       @BenchmarkMode(Mode.Throughput)
       public void getThreadMetrics(Blackhole bh) {
           bh.consume(ClassProvider.INSTANCE.getClassMetrics());
       }
   
       public static void main(String[] args) throws Exception {
           Options opt = new 
OptionsBuilder().include(ClassProviderBenchmark.class.getSimpleName())
                   .build();
           new Runner(opt).run();
       }
   
       /**
        # JMH version: 1.21
        # VM version: JDK 1.8.0_231, Java HotSpot(TM) 64-Bit Server VM, 
25.231-b11
        # VM invoker: 
/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/jre/bin/java
        # VM options: -javaagent:/Users/switch/Library/Application 
Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.7442.40/IntelliJ 
IDEA.app/Contents/lib/idea_rt.jar=52931:/Users/switch/Library/Application 
Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.7442.40/IntelliJ 
IDEA.app/Contents/bin -Dfile.encoding=UTF-8
        # Warmup: 5 iterations, 10 s each
        # Measurement: 5 iterations, 10 s each
        # Timeout: 10 min per iteration
        # Threads: 1 thread, will synchronize iterations
        # Benchmark mode: Throughput, ops/time
        *
        * Benchmark                                 Mode  Cnt        Score      
Error  Units
        * ClassProviderBenchmark.getThreadMetrics  thrpt   25  6542809.978 ± 
8794.520  ops/s
        */
   }
   ```
   
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to