Tencent / TencentKona-8

Tencent Kona is a no-cost, production-ready distribution of the Open Java Development Kit (OpenJDK), Long-term support(LTS) with quarterly updates. Tencent Kona serves as the default JDK internally at Tencent Cloud for cloud computing and other Java applications.
Other
938 stars 146 forks source link

Transplant jmh test OneShot.java from Loom #121

Closed Jong111 closed 1 year ago

Jong111 commented 1 year ago

Main changes

  1. Create a standalone Maven project to meet the needs of JMH, including a pom.xml file, a Java class file, and a txt file which contains the result of the OneShot test
  2. Remove the import of jdk.internal.vm.Continuation and jdk.internal.vm.ContinuationScope, which is no need in the test

Detailed diff

-import jdk.internal.vm.Continuation;
-import jdk.internal.vm.ContinuationScope;
-
 import java.util.concurrent.TimeUnit;

 import org.openjdk.jmh.annotations.*;
@@ -210,15 +207,22 @@ public class OneShot {
     }

     /**
-     * Creates and runs a continuation that yields at a given stack depth.
+     This benchmark will continuously create new continuations, which in KonaFiber means that
+     the program will keep requesting native memory and eventually run out of native memory,
+     so the benchmark will get a runtime error in KonaFiber. While running the benchmark with Loom
+     does not have this problem, because Loom creates the continuation in the JVM heap space,
+     and the stacked continuation will be cleaned up by the GC mechanism.
      */
-    @Benchmark
-    public void yield() {
-        Continuation cont = Yielder.continuation(paramCount, stackDepth, true);
-        cont.run();
-        if (cont.isDone())
-            throw new RuntimeException("continuation done???");
-    }
+//    /**
+//     * Creates and runs a continuation that yields at a given stack depth.
+//     */
+//    @Benchmark
+//    public void yield() {
+//        Continuation cont = Yielder.continuation(paramCount, stackDepth, true);
+//        cont.run();
+//        if (cont.isDone())
+//            throw new RuntimeException("continuation done???");
+//    }
johnshajiang commented 1 year ago

@Jong111 You may also want to provide a README.md for clarifying the way to build and run this test.

Jong111 commented 1 year ago

@Jong111 You may also want to provide a README.md for clarifying the way to build and run this test. ok, i will add it

miao-zheng commented 1 year ago
  1. 在readme里面没有看到测试结果,也没有loom的测试结果;
  2. 没有在comment里看到,git diff列出当前文件和loom原始文件的差异
Jong111 commented 1 year ago
  1. 在readme里面没有看到测试结果,也没有loom的测试结果;
  2. 没有在comment里看到,git diff列出当前文件和loom原始文件的差异

回复1:我将kona_fiber的测试结果放在了oneshot_test_result.txt中,您可以在该文件中查看,我需要将其转移到readme中吗?之后我把loom的测试结果也上传到指定文件; 回复2:感谢您的指出,之后我会上传Main.java和原始的OneShot.java之间的差异,请问是将git diff的结果作为注释保存在Main.java中还是单独新建一个文件保存?

miao-zheng commented 1 year ago

不需要新建一个文件,只要在comment里列出来就行

Jong111 commented 1 year ago

不需要新建一个文件,只要在comment里列出来就行

好的

miao-zheng commented 1 year ago

看了git diff的文件,还是有很多非必要的改动,比如:

-                case 1: run1(maxDepth); break;
-                case 2: run2(maxDepth, new Arg()); break;
-                case 3: run3(maxDepth, new Arg(), new Arg()); break;
-                default: throw new Error("should not happen");
+                case 1:
+                    run1(maxDepth);
+                    break;
+                case 2:
+                    run2(maxDepth, new Arg());
+                    break;
+                case 3:
+                    run3(maxDepth, new Arg(), new Arg());
+                    break;
+                default:
+                    throw new Error("should not happen");
             }

建议这些非必要的改动全部去掉

Jong111 commented 1 year ago

看了git diff的文件,还是有很多非必要的改动,比如:

-                case 1: run1(maxDepth); break;
-                case 2: run2(maxDepth, new Arg()); break;
-                case 3: run3(maxDepth, new Arg(), new Arg()); break;
-                default: throw new Error("should not happen");
+                case 1:
+                    run1(maxDepth);
+                    break;
+                case 2:
+                    run2(maxDepth, new Arg());
+                    break;
+                case 3:
+                    run3(maxDepth, new Arg(), new Arg());
+                    break;
+                default:
+                    throw new Error("should not happen");
             }

建议这些非必要的改动全部去掉

好的,已经改了