-
Notifications
You must be signed in to change notification settings - Fork 324
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
Native Language Server integration with PM #11880
Conversation
The first attempt at a) building `enso` native-image that includes full Language Server b) integrating the executable as an experimental feature during project startup The change (for now) assumes that `enso` executable appears in Enso's default `engines` directory. To build and run the new integration one has to a) `engine-runner/buildNativeImage` b) run PM with `--native-language-server` This change also adds a copy of some of logback's code (`SocketAppender` or a simple socket server`) as it was impossible to debug serialization bugs without some additional logging.
Otherwise Akka and other code is simply dead-code eliminated in native-image.
When message transport is missing, context should be properly built, even in AOT mode.
Problems revealed after a clean build
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.
- I am glad to see language server startup improvement
- that's what native image technology is good for and I am glad to see it delivers on its promise
- for a while I was confused by the dependency changes
- looks like it is mostly to access
TruffleOptions.AOT
from the non-Truffle part of our codebase - please keep Truffle API out of the dependencies of launcher, boot, etc. projects
- use Boolean.getBoolean("com.oracle.graalvm.isaot") directly
- I suggest to avoid introduction of
--native-...
CLI options- we may not need them at all at this stage
- just prefer
bin/enso
orbin\enso.exe
native binary when it exists - there already is well functioning
--jvm
option - we may want to expose it from project manager CLI, but
- it is already accessible via
ENSO_OPTS
and that may be enough for now
- I suggest to separate separate
*-config.json
and put them intolanguage-server
source tree - I am glad to see the Launching Enso programs instantly #10121 work moving forward
@@ -228,6 +232,19 @@ public Context build() { | |||
.allowCreateThread(true); | |||
} | |||
|
|||
if (engineOptions != null) { | |||
// In AOT mode one must not use a shared engine; the latter causes issues when initializing | |||
// message transport - it is set to `null`. |
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.
Interesting. I don't see a reason wny transport shouldn't work. Maybe it is a bug. Do we have a (small) reproducer that we could report to GraalVM guys and find out what they think?
...er/src/main/java/org/enso/interpreter/instrument/runtime/server/RuntimeServerInstrument.java
Show resolved
Hide resolved
@@ -108,7 +108,7 @@ public void onContextClosed(TruffleContext context) {} | |||
@Override | |||
protected void onCreate(Env env) { | |||
this.env = env; | |||
env.registerService(this); | |||
|
|||
if (TruffleOptions.AOT) { |
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.
The usage of TruffleOptions.AOT
is correct here as this is a Truffle instrument and it needs dependency on Truffle API.
lib/scala/project-manager/src/main/scala/org/enso/projectmanager/boot/Cli.scala
Outdated
Show resolved
Hide resolved
...version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/NativeJavaCommand.scala
Outdated
Show resolved
Hide resolved
...la/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/Runner.scala
Outdated
Show resolved
Hide resolved
Despite being advertised as such, native image doesn't set `com.oracle.graalvm.isaot` and it has to be provided separately if we don't want to use `TruffleOptions`.
...r/src/main/resources/META-INF/native-image/org/enso/languageserver/serialization-config.json
Show resolved
Hide resolved
Context creation for AOT needs to define a separate Engine configuration rather than using a shared engine to be able to use message transport.
engine: Engine, | ||
jvmSettings: JVMSettings | ||
): Seq[String] = | ||
Seq("-Dcom.oracle.graalvm.isaot=true") |
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.
Interesting. Why do we need to provide this argument?
- I would expect it is only useful at image built time
- or that it is provided by default
- btw. Native Image API offers some checks like this too
E.g. if we can access org.graalvm.nativeimage.ImageInfo
then we can query "properly" and even distinguish between build time and runtime time.
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.
The property is completely missing during runtime, hence not allowing me to provide different Context configuration.
The description should be updated as
may no longer reflect the reality after 3ce2577 |
Congratulation on merging and making another step towards using native binaries as GUI backend. Notes:
This is the top ten of included packages:
|
Previosly we were wrongly relying on the presence of the file. That way, a bash script meant that NI integration was wrongly used. This change uses Tika, but it has already been present in other subprojects so no additional dependency shall be added. Follow up on #11880.
Pull Request Description
The first attempt at
enso
native-image that includes full Language ServerThe change (for now) assumes that
enso
executable appears in Enso's defaultengines
directory.To build and run the new integration one has to
engine-runner/buildNativeImage
The Runner will automatically detect the presence of a native image and attempt to run LS in AOT mode.
This change also adds a copy of some of logback's code (a simple socket server) as it was impossible to debug serialization bugs without some additional logging. Potentially to be removed in the final PR.
This is by no means a final change in this area. We need to make it possible to include all other
Standard
libs, at least. But it's a step forward that allows devs to experiment.Important Notes
There is a change in
JsonConnectionController
which only sets the controller as initialized when all resources are set up. Previously, it seems, the asynchronous setup could lead to some race conditions.Exchange between LS and GUI (before):
(after)
As one can see, speedup in startup is rather massive.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.