Skip to content

Channel connecting two JVM instances #13206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
64fd1ac
Sending messages between two JVMs with the help of Persistance.Pool
JaroslavTulach May 30, 2025
2e3911c
ExecuteMainClass message doesn't have a return value
JaroslavTulach May 30, 2025
5b42e1d
Exchange messages between JVMs. Send ReportResult back.
JaroslavTulach Jun 2, 2025
9dc5646
Introducing channel between two JVMs
JaroslavTulach Jun 2, 2025
4d69228
Using RequestFactorial message
JaroslavTulach Jun 2, 2025
1e753eb
Message with a result
JaroslavTulach Jun 2, 2025
d7d547b
Return BigInteger result
JaroslavTulach Jun 2, 2025
879a092
Remove runtime dependency on Lookup
JaroslavTulach Jun 2, 2025
a23cdd5
Back and forth computation of factorial
JaroslavTulach Jun 2, 2025
eeab6a9
Enabling Foreign API support
JaroslavTulach Jun 2, 2025
cf02db1
Moving Channel and Message into their own class
JaroslavTulach Jun 3, 2025
32aa5b0
Handling executeMain the old way to avoid access checks associated wi…
JaroslavTulach Jun 3, 2025
22de1c4
Removing usage of NetBeans Lookup from benchmarks
JaroslavTulach Jun 3, 2025
5e1a8e7
Removing org-openide-util-lookup from componentModulesPaths to fix JP…
JaroslavTulach Jun 3, 2025
e28e6ea
Allocate both peers of the Channel at once
JaroslavTulach Jun 3, 2025
7133830
Look a Channel peer up by its ID
JaroslavTulach Jun 3, 2025
3f16786
Add debugging symbols when ENSO_LAUNCHER=debug
JaroslavTulach Jun 3, 2025
b04963d
Multiple nested callbacks are possible
JaroslavTulach Jun 3, 2025
d11a0cf
Allow implementation of Channel messages as records
JaroslavTulach Jun 3, 2025
42d24f4
Avoid global pool reference when local one is available
JaroslavTulach Jun 3, 2025
21fb777
Load pool from a specified Class supplying it
JaroslavTulach Jun 3, 2025
bc9aab7
Public factory method to create a Channel
JaroslavTulach Jun 3, 2025
4531025
RuntimeVisualizationsTest uses HandlerFactory
JaroslavTulach Jun 4, 2025
fa46a7c
Basic handling of exceptions in the other JVM
JaroslavTulach Jun 4, 2025
0445962
Propagate exceptions back and forth among JVMs
JaroslavTulach Jun 4, 2025
93c6fd5
Allocate the method handle at Channel creation time
JaroslavTulach Jun 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 38 additions & 23 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ lazy val componentModulesPaths =
jline ++
slf4jApi ++
Seq(
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion,
"org.netbeans.api" % "org-netbeans-modules-sampler" % netbeansApiVersion,
"com.google.flatbuffers" % "flatbuffers-java" % flatbuffersVersion,
"com.google.protobuf" % "protobuf-java" % googleProtobufVersion,
Expand Down Expand Up @@ -2141,13 +2140,10 @@ lazy val `persistance` = (project in file("lib/java/persistance"))
Compile / javacOptions := ((Compile / javacOptions).value),
inConfig(Compile)(truffleRunOptionsSettings),
libraryDependencies ++= slf4jApi ++ Seq(
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion,
"junit" % "junit" % junitVersion % Test,
"com.github.sbt" % "junit-interface" % junitIfVersion % Test
"junit" % "junit" % junitVersion % Test,
"com.github.sbt" % "junit-interface" % junitIfVersion % Test
),
Compile / moduleDependencies ++= slf4jApi ++ Seq(
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NetBeans Lookup shouldn't be used during runtime: 879a092

)
Compile / moduleDependencies ++= slf4jApi
)
.dependsOn(`persistance-dsl` % Test)

Expand Down Expand Up @@ -3356,12 +3352,12 @@ lazy val `runtime-parser` =
commands += WithDebugCommand.withDebug,
fork := true,
libraryDependencies ++= Seq(
"junit" % "junit" % junitVersion % Test,
"com.github.sbt" % "junit-interface" % junitIfVersion % Test,
"org.scalatest" %% "scalatest" % scalatestVersion % Test
"junit" % "junit" % junitVersion % Test,
"com.github.sbt" % "junit-interface" % junitIfVersion % Test,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided"
),
Compile / moduleDependencies ++= Seq(
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion
),
// Java compiler is not able to correctly find all the annotation processors, because
// one of them is on module-path. To overcome this, we explicitly list all of them here.
Expand Down Expand Up @@ -3643,9 +3639,10 @@ lazy val `runtime-instrument-common` =
"ENSO_TEST_DISABLE_IR_CACHE" -> "false"
),
libraryDependencies ++= Seq(
"junit" % "junit" % junitVersion % Test,
"com.github.sbt" % "junit-interface" % junitIfVersion % Test,
"org.scalatest" %% "scalatest" % scalatestVersion % Test
"junit" % "junit" % junitVersion % Test,
"com.github.sbt" % "junit-interface" % junitIfVersion % Test,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % Test
),
javaModuleName := "org.enso.runtime.instrument.common",
Compile / moduleDependencies ++= slf4jApi ++ Seq(
Expand Down Expand Up @@ -3739,12 +3736,11 @@ lazy val `runtime-instrument-runtime-server` =
Compile / forceModuleInfoCompilation := true,
instrumentationSettings,
Compile / moduleDependencies ++= Seq(
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion,
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion,
"org.graalvm.sdk" % "collections" % graalMavenPackagesVersion,
"org.graalvm.sdk" % "word" % graalMavenPackagesVersion,
"org.graalvm.sdk" % "nativeimage" % graalMavenPackagesVersion,
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion,
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion,
"org.graalvm.sdk" % "collections" % graalMavenPackagesVersion,
"org.graalvm.sdk" % "word" % graalMavenPackagesVersion,
"org.graalvm.sdk" % "nativeimage" % graalMavenPackagesVersion
),
Compile / internalModuleDependencies := Seq(
(`runtime-instrument-common` / Compile / exportedModule).value,
Expand Down Expand Up @@ -4006,6 +4002,7 @@ lazy val `engine-runner` = project
"-H:+AddAllCharsets",
"-H:+IncludeAllLocales",
"-H:+RunReachabilityHandlersConcurrently",
"-H:+ForeignAPISupport",
"-R:-InstallSegfaultHandler",
// Workaround a problem with build-/runtime-initialization conflict
// by disabling this service provider
Expand Down Expand Up @@ -4313,6 +4310,7 @@ lazy val `os-environment` =
),
Compile / internalModuleDependencies ++= Seq(
(`engine-common` / Compile / exportedModule).value,
(`persistance` / Compile / exportedModule).value,
Copy link
Member Author

@JaroslavTulach JaroslavTulach Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os-environment now contains support for passing Messages via Channel. Messages serde is handled via persistance - hence the dependency.

(`logging-utils` / Compile / exportedModule).value,
(`logging-config` / Compile / exportedModule).value
),
Expand All @@ -4331,8 +4329,24 @@ lazy val `os-environment` =
additionalOptions = Seq(
"-ea",
"--features=org.enso.os.environment.TestCollectorFeature",
"-H:+ForeignAPISupport",
"-R:-InstallSegfaultHandler"
)
) ++ (if (GraalVM.EnsoLauncher.debug) {
// useful perf & debug switches:
Seq(
"-g",
"-O0",
"-H:+SourceLevelDebug",
"-H:-DeleteLocalSymbols",
// you may need to set smallJdk := None to use following flags:
// "--trace-class-initialization=org.enso.syntax2.Parser",
// "--diagnostics-mode",
// "--verbose",
"-Dnic=nic"
)
} else {
Seq()
})
)
}.value,
Test / test := Def
Expand All @@ -4352,6 +4366,8 @@ lazy val `os-environment` =
.value,
Test / fork := true
)
.dependsOn(`persistance`)
.dependsOn(`persistance-dsl` % "provided")
.dependsOn(`engine-common`)

lazy val `bench-processor` = (project in file("lib/scala/bench-processor"))
Expand Down Expand Up @@ -4379,8 +4395,7 @@ lazy val `bench-processor` = (project in file("lib/scala/bench-processor"))
"org.netbeans.modules.openide.util.ServiceProviderProcessor"
)),
Compile / moduleDependencies := Seq(
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion,
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion
),
Compile / internalModuleDependencies := Seq(
(`engine-common` / Compile / exportedModule).value,
Expand Down
5 changes: 0 additions & 5 deletions distribution/engine/THIRD-PARTY/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,6 @@ The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `org.netbeans.api.org-netbeans-modules-sampler-RELEASE180`.


'org-openide-util-lookup', licensed under the The Apache Software License, Version 2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `org.netbeans.api.org-openide-util-lookup-RELEASE180`.


'reactive-streams', licensed under the CC0, is distributed with the engine.
The license file can be found at `licenses/CC0`.
Copyright notices related to this dependency can be found in the directory `org.reactivestreams.reactive-streams-1.0.3`.
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion engine/runtime-compiler/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
requires org.enso.syntax;
requires org.enso.scala.wrapper;

requires org.openide.util.lookup.RELEASE180;
requires org.slf4j;

exports org.enso.compiler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
requires org.enso.engine.common;
requires org.enso.distribution;
requires org.enso.lockmanager;
requires org.openide.util.lookup.RELEASE180;
requires org.graalvm.polyglot;
requires org.graalvm.truffle;

provides com.oracle.truffle.api.instrumentation.provider.TruffleInstrumentProvider with
org.enso.interpreter.instrument.runtime.server.RuntimeServerInstrumentProvider;

uses org.enso.interpreter.instrument.HandlerFactory;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.net.URI;
import java.util.Arrays;
import java.util.Optional;
import java.util.ServiceLoader;
import org.enso.distribution.locking.LockManager;
import org.enso.interpreter.instrument.Handler;
import org.enso.interpreter.instrument.HandlerFactory;
Expand All @@ -25,7 +26,6 @@
import org.graalvm.options.OptionDescriptors;
import org.graalvm.polyglot.io.MessageEndpoint;
import org.graalvm.polyglot.io.MessageTransport;
import org.openide.util.Lookup;

/**
* An instrument exposing a server for other services to connect to, in order to control the current
Expand Down Expand Up @@ -112,8 +112,9 @@ protected void onCreate(Env env) {
if (TruffleOptions.AOT) {
this.handler = HandlerFactoryImpl.create();
} else {
var loadedHandler = Lookup.getDefault().lookup(HandlerFactory.class);
this.handler = loadedHandler != null ? loadedHandler.create() : HandlerFactoryImpl.create();
var loadedHandler = ServiceLoader.load(HandlerFactory.class).findFirst();
this.handler =
loadedHandler.isPresent() ? loadedHandler.get().create() : HandlerFactoryImpl.create();
}

try {
Expand Down
1 change: 1 addition & 0 deletions lib/java/os-environment/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Image.
*/
module org.enso.os.environment {
requires org.enso.persistance;
requires org.enso.engine.common;
requires org.graalvm.nativeimage;
requires org.slf4j;
Expand Down
Loading
Loading