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.
1.Create a standalone Maven project to meet the needs of JMH
2.To make it compatible with KonaJDK8, replace the keyword var with the corresponding type when declaring variables.
Detailed diff output
diff --git a/Skynet.java b/Skynet.java
index a9255dd..b64ef58 100644
--- a/Skynet.java
+++ b/Skynet.java
@@ -20,7 +20,8 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package org.openjdk.bench.loom;
+package com.example;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
@@ -46,7 +47,7 @@ import java.util.concurrent.TimeUnit;
@SuppressWarnings("preview")
public class Skynet {
- @Param({"1000000"})
+ /*
+ * The original default value of 1,000,000 for this parameter would cause excessive computational
+ * overhead and memory usage during training, resulting in a program that cannot run successfully.
+ * To maintain stability and ensure successful execution, we set a smaller default value of 100,000 instead.
+ */
+ @Param({"100000"})
public int num;
static class Channel<T> {
@@ -89,9 +90,9 @@ public class Skynet {
static void skynet(Channel<Long> result, int num, int size, int div) {
if (size == 1) {
result.send((long) num);
} else {
- var chan = new Channel<Long>();
+ Channel<Long> chan = new Channel<>();
for (int i = 0; i < div; i++) {
int subNum = num + i * (size / div);
Thread.startVirtualThread(() -> skynet(chan, subNum, size / div, div));
@@ -106,7 +107,7 @@ public class Skynet {
@Benchmark
public long skynet() {
- var chan = new Channel<Long>();
+ Channel<Long> chan = new Channel<>();
Thread.startVirtualThread(() -> skynet(chan, 0, num, 10));
return chan.receive();
}
Main changes
1.Create a standalone Maven project to meet the needs of JMH 2.To make it compatible with KonaJDK8, replace the keyword var with the corresponding type when declaring variables.
Detailed diff output