Skip to content

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Mar 14, 2025

Pull Request Description

Changes project-manager to execute enso launcher in native image mode by default. Provides an opt-out (as requested by #12483) by honoring ENSO_JVM_OPTS in the project-manager. If ENSO_JVM_OPTS variable is provided, the enso launcher is executed in JVM mode (as was the case so far).

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has not been updated - ENSO_JVM_OPTS is mostly development only property
    • there will be better user facing switch available soon
  • All code follows the
    Scala,
  • Unit tests continue to work
  • Manually verified

@jdunkerley
Copy link
Member

The memory options work for Native Image as well (I believe - at least seem to), and are useful so would be better to have these as separate options.

Copy link
Collaborator

@hubertp hubertp left a comment

Choose a reason for hiding this comment

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

I'm not really convinced about this change. People tend to set their options globally or reuse them in various scripts. So this can cause more harm than good by leading to some unexpected behaviour. I'd rather we make this explicit.

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Mar 15, 2025

The memory options work for Native Image as well (I believe - at least seem to), and are useful so would be better to have these as separate options.

How do you set memory options work for Native Image?

Btw. I've noticed that ENSO_JVM_OPTS are used as enso executable arguments when launching native image enso executable. If that's what you are referring to @jdunkerley, then that's pretty dangerous - that means (with the expected introduction of JVM/NI switch in package.yaml) that the ENSO_JVM_OPTS change their interpretation when changing JVM/NI mode.

That's quite confusing and it will have to be changed anyway.

@JaroslavTulach JaroslavTulach linked an issue Mar 15, 2025 that may be closed by this pull request
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Mar 15, 2025

I'm not really convinced about this change. People tend to set their options globally or reuse them in various scripts. So this can cause more harm than good by leading to some unexpected behaviour. I'd rather we make this explicit.

  • setting ENSO_JVM_OPTS is explicit
  • I don't expect any of the Enso target audience users to have ENSO_JVM_OPTS set. Am I wrong?
  • moreover as pointed out here the meaning of ENSO_JVM_OPTS changes currently - which makes little sense
  • ENSO_JVM_OPTS are JVM options - e.g. they should be applied only to JVM mode.
  • as such I don't think Enso users would be seeing anything unexpected

@JaroslavTulach JaroslavTulach changed the title Only use JVM mode when ENSO_JVM_OPTS is set Make NI mode the default unless an env variable is set Mar 15, 2025
@JaroslavTulach JaroslavTulach changed the title Make NI mode the default unless an env variable is set Let's use NI mode the default unless an env variable is set Mar 15, 2025
@JaroslavTulach JaroslavTulach changed the title Let's use NI mode the default unless an env variable is set Let's use NI mode by default unless an env variable is set Mar 15, 2025
@JaroslavTulach JaroslavTulach self-assigned this Mar 15, 2025
@JaroslavTulach JaroslavTulach force-pushed the wip/jtulach/JvmModeWhenEnsoJvmOpts12483 branch from a6b5790 to b6f3d00 Compare March 15, 2025 05:46
@jdunkerley
Copy link
Member

Some of our users are using this flag as it is what we have provided so far - we can provide an alternative to adjust the memory settings which would allow us more control.

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Mar 16, 2025

Some of our users are using this flag as it is what we have provided so far

With the change in this PR such users should see (completely) compatible behavior. If they have ENSO_JVM_OPTS for example to increase memory, the memory will continue to be increased as we launch in JVM mode and apply exactly the same settings.

we can provide an alternative to adjust the memory settings which would allow us more control.

The GraalVM Launcher API differentiates between --vm.xyz option and --jvm.xyz option. The former one is applied to both modes (native one as well as JVM one). Usage of the latter turns on the JVM mode and applies both vm and jvm options.

Such a scheme is standard for all GraalVM language launchers and we should mimic it. We couldn't do it so far, as the scheme only works if the native mode is the default one. A bit more investigation into behavior of the GraalVM launchers is needed as we aren't directly using the launcher infrastructure ...

... just trying to mimic it ourselves.

@JaroslavTulach JaroslavTulach changed the title Let's use NI mode by default unless an env variable is set Use NI mode by default unless an env variable is set Mar 16, 2025
@hubertp hubertp mentioned this pull request Mar 16, 2025
2 tasks
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Mar 17, 2025

Nightly release CI run scheduled.

  • after downloading and unzipping
  • and executing ./enso-linux-x86_64-2025.1.1-nightly.2025.3.17.1.AppImage --no-sandbox
  • there still is Running Language Server in JVM mode
  • e.g. the change in this PR doesn't seem to work

Not sure where exactly the problem is. When I do:

$ ./enso-linux-x86_64-2025.1.1-nightly.2025.3.17.1.AppImage --appimage-extract
$ ls -l squashfs-root/resources/enso/dist/2025.1.1-nightly.2025.3.17.1/bin/enso -h
-rwxr-xr-x 1 devel devel 480M bře 17 11:30 squashfs-root/resources/enso/dist/2025.1.1-nightly.2025.3.17.1/bin/enso

e.g. the enso native image binary is present in the AppImage.

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Mar 17, 2025

How do you set memory options work for Native Image?

James has just provided a link to https://www.graalvm.org/latest/reference-manual/native-image/optimizations-and-performance/MemoryManagement/#java-heap-size

The memory options work for Native Image as well

Thus I assume following example is the way to set memory options work for Native Image with 2025.1.1-nightly.2025.3.17:

enso$ export ENSO_LAUNCHER=native
enso$ export ENSO_JVM_OPTS=-Xms2m -Xmx10m -Xmn1m
enso$ ./project-manager

The above then launches enso in native image mode and provides memory settings to it. Such a scenario will not work anymore with this PR - with this PR the above would launch enso in JVM mode and pass the memory settings to the JVM.

@JaroslavTulach
Copy link
Member Author

Closing unmerged as:

mergify bot pushed a commit that referenced this pull request Mar 17, 2025
This change makes Native Image build opt-out rather than opt-in. To use JVM mode, IDE has to start with `--jvm` or `ENSO_LAUNCHER=shell`.

An alternative approach to #12501. Closes #12483.
Likely also addresses #12303.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Native Image opt-out
3 participants