Open HangerLIN opened 1 year ago
@HangerLIN
Please remove directory target
.
How to Run the Test Make sure Java 1.8.0_362_fiber is installed. Run the command mvn clean packageto build the project. Run the main method in the class org.example.Ring to start the test. See the result in the file res.json changes: Add jmh dependencies in pom.xml
<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.37</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.37</version>
</dependency>
</dependencies>
Altered the Method for Starting Workers:
In the Loom version, the getChannel() method used the enhanced switch expression syntax:
return switch(stackFrame) {
...
default -> throw new RuntimeException("Illegal stack parameter value: "+ stackFrame +" (allowed: 1,2,4,8)");
};
In the Kona version, I changed it back to the conventional switch statement since the arrow syntax used in “switch” only can be complied in jdk 14 or other later version.
switch (stackFrame) {
...
default:
throw new RuntimeException("Illegal stack parameter value: " + stackFrame + " (allowed: 1,2,4,8)");
}
Here is the git diff between the original one and the version I made it adapted to Kona.
git diff /Users/lth/Downloads/loom-fibers/test/micro/org/openjdk/bench/loom/ring/Ring.java /Users/lth/Desktop/OpenSourceRecord/kona_copy/TencentKona-8/demo/fiber/Ring_test/src/main/java/org/example/Ring.java
diff --git a/Users/lth/Downloads/loom-fibers/test/micro/org/openjdk/bench/loom/ring/Ring.java b/Users/lth/Desktop/OpenSourceRecord/kona_copy/TencentKona-8/demo/fiber/Ring_test/src/main/java/org/example/Ring.java
old mode 100755
new mode 100644
index 58f74586..98d50663
--- a/Users/lth/Downloads/loom-fibers/test/micro/org/openjdk/bench/loom/ring/Ring.java
+++ b/Users/lth/Desktop/OpenSourceRecord/kona_copy/TencentKona-8/demo/fiber/Ring_test/src/main/java/org/example/Ring.java
@@ -20,8 +20,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package org.openjdk.bench.loom.ring;
+package org.example;
+import org.example.Channel;
+import org.example.Channels;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
@@ -92,7 +94,6 @@ public class Ring {
@Param({"true", "false"})
public boolean singleshot;
-
@Setup
@SuppressWarnings("unchecked")
public void setup() {
@@ -154,14 +155,18 @@ public class Ring {
}
Channel<Integer> getChannel() {
- return switch(stackFrame) {
- case 1 -> new Channels.ChannelFixedStackR1<>(getQueue(queue), stackDepth, allocalot ? 4242 : 0);
- case 2 -> new Channels.ChannelFixedStackR2<>(getQueue(queue), stackDepth, allocalot ? 4242 : 0);
- case 4 -> new Channels.ChannelFixedStackR4<>(getQueue(queue), stackDepth, allocalot ? 4242 : 0);
- case 8 -> new Channels.ChannelFixedStackR8<>(getQueue(queue), stackDepth, allocalot ? 4242 : 0);
- default -> throw new RuntimeException("Illegal stack parameter value: "+ stackFrame +" (allowed: 1,2,4,8)");
- };
-
+ switch (stackFrame) {
+ case 1:
+ return new Channels.ChannelFixedStackR1<>(getQueue(queue), stackDepth, allocalot ? 4242 : 0);
+ case 2:
+ return new Channels.ChannelFixedStackR2<>(getQueue(queue), stackDepth, allocalot ? 4242 : 0);
:
我已经修改了描述文档,请老师过目
我只是确定一下,上面的diff
的内容是否显示完整了?是否会一些末尾的行没有显示出来?
至少看起来,switch语句中有些条目,如4,8和default,没有列出来。
我是把原本在终端栏的全部信息都复制上来了
是不是一屏幕不能显示出全部内容?
结尾处是:
,我以为后面还有内容。可以把光标继续向下移动。
按照和老师会议谈论内容增加了Ring.java以及 Channel.java的实现逻辑和结果
How to Run the Test
mvn clean package
to build the project.org.example.Ring
to start the test.res.json
changes:
Add jmh dependencies in pom.xml
Altered the Method for Starting Workers:
startAll()
method was usingThread.startVirtualThread(w);
to start virtual threads.Thread.ofVirtual().scheduler(Executors.newSingleThreadExecutor()).start(w);
to start the virtual threads as well.Modified Channel Creation:
getChannel()
method used the enhanced switch expression syntax: