-
Notifications
You must be signed in to change notification settings - Fork 330
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
Conversation
✨ GUI Checks ResultsSummary
See individual check results for more details. |
), | ||
Compile / moduleDependencies ++= slf4jApi ++ Seq( | ||
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion |
There was a problem hiding this comment.
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
@@ -4313,6 +4311,7 @@ lazy val `os-environment` = | |||
), | |||
Compile / internalModuleDependencies ++= Seq( | |||
(`engine-common` / Compile / exportedModule).value, | |||
(`persistance` / Compile / exportedModule).value, |
There was a problem hiding this comment.
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 Message
s via Channel
. Messages serde is handled via persistance
- hence the dependency.
import org.graalvm.nativeimage.c.type.CCharPointer; | ||
import org.graalvm.nativeimage.c.type.CTypeConversion; | ||
|
||
/** Channel connects two {@link JVM} instances. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since e28e6ea the channels are allocated in pairs. There is always an SubstrateVM side and HotSpot JVM side of the channel. Right now these two sides are going to have the same ID stored in ID_TO_CHANNEL
map.
Function<MemorySegment, Long> send) { | ||
try (var arena = Arena.ofConfined()) { | ||
var bytes = pool.write(msg, null); | ||
var memory = arena.allocate(Math.max(bytes.length, 4096)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Current limitation: the size of reply cannot be bigger than size of request or 4096.
- I guess we can live with it and integrate
- then proceed with other parts of Dual NI + JVM Mode for Loading Libraries #13172 to execute something in the other JVM
- then go back and fix this limitation and also do some performance work
Persistance.Pool
Debugging the HotSpot codeOne can influence HotSpot virtual machine options created by the enso$ sbt os-environment/test
enso$ _JAVA_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=5005 ./test-os-env
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) E.g. instruct your IDE to listen on 5005 port and debug the code running in HotSpot JVM. Btw:
|
Persistance.Pool
Channel
connecting two JVM
instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Few minor comments inline.
lib/java/os-environment/src/main/java/org/enso/os/environment/jni/Channel.java
Show resolved
Hide resolved
lib/java/os-environment/src/main/java/org/enso/os/environment/jni/Channel.java
Show resolved
Hide resolved
lib/java/os-environment/src/test/java/org/enso/os/environment/jni/LoadClassTest.java
Show resolved
Hide resolved
Our CI is reporting problems with this change on MacOS ARM:
https://github.com/enso-org/enso/actions/runs/15457103830/job/43511280601#step:10:3634
|
I guess I should have read this GraalVM document sooner:
I'll think about alternative approaches today:
|
Pull Request Description
JVM
class with support for extensible messages to be transferred between the two JVMsPersistable.Pool
to group related instances into pool #13201Usage
PoolOfMessages
must be available forClass.forName
in thejvm
- either on classpath or module path.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
Message
- back and forth factorialMessage
- donePool
with other messagesPool
on both sides of theChannel