Skip to content
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

Universal Main #1729

Merged
merged 5 commits into from
Feb 5, 2022
Merged

Universal Main #1729

merged 5 commits into from
Feb 5, 2022

Conversation

lefou
Copy link
Member

@lefou lefou commented Feb 3, 2022

This PR is an attempt to improve the startup process of Mill. Currently, to run in different modes (client/server, standalone/no-server) we use different entry points which reside in different classes. Also, the client main is implemented in pure Java to improve the startup time of the client (by keep classloading at a minimum). To reflect the different entry points, we currently need a rather sophisticated start script. Although this PR does not simplify the process as such, it simplifies it's user side by supporting all modes through only one main class, the mill.main.client.MillClientMain. That way the good startup times in client mode remain.

Because we handle all modes in a single point, we can better handle server startup issues. E.g. we can now gracefully fall back to a in-process or sub-process runner when the server runner can not be properly started. This should improve the user experience on some Windows setups and newer M1 Macs a lot.

I didn't removed the complexity of the startup script for now, but simply ensured it always calls the client main.

The client main now ensures that custom JVM properties (.mill-jvm-opts) are properly applied in case we can't start the server and will, if necessary, start in a sub-process (with properly applied JVM options) instead of in-process.

The .mill-version is currently not handled (as before), but there is no reason that we could not detect a mismatch and even implement fetching and starting of another version in future.

So, this PR should also improve the way Mill can be embedded into other tools or launcher, like coursier.

I have no idea how to test all this automatically, so I tried to test as much locally as possible, but any help in testing this, especially in edge cases like special environments, high load scenarios, many mill server instances (e.g. with different JVMs) would be really appreciated.

We have a Java-based client for faster speed up.
With this change we can now rudimentary detect if we should not run in client-mode
because the user said so (e.g. (-i, --no-server) or we can't start the server.
Also more refactoring to share logic.

Added --bsp to non-server selectors.
@lolgab
Copy link
Member

lolgab commented Feb 4, 2022

This is a great improvement for Mill. I tested on my biggest project and I didn't notice any problem. I'd say to merge this and let users test it before releasing 0.10.1.

@lefou lefou merged commit c556181 into com-lihaoyi:main Feb 5, 2022
@lefou lefou deleted the universal-main branch February 5, 2022 16:00
@lefou lefou added this to the after 0.10.0 milestone Feb 5, 2022
@justf0rfun
Copy link

justf0rfun commented Aug 20, 2022

The documentation still says that installing Mill via coursier is unsupported:

Coursier (unsupported)

Installing mill via coursier or cs is currently not officially supported. There are various issues, especially with interactive mode.

https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_coursier_unsupported

When this PR is merged is are the docs still right on this or should they be updated? If other blocking issues exist where are these issues filed? The only issue I found is this in coursier's repo which directs to this PR.

@lefou
Copy link
Member Author

lefou commented Aug 20, 2022

The documentation still says that installing Mill via coursier is unsupported:

Coursier (unsupported)
Installing mill via coursier or cs is currently not officially supported. There are various issues, especially with interactive mode.

https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_coursier_unsupported

When this PR is merged is are the docs still right on this or should they be updated? If other blocking issues exist where are these issues filed? The only issue I found is this in coursier's repo which directs to this PR.

This is a good question. I didn't follow recent changes in coursier and it's installable apps. If there is only one Mill app which is running the Mill client, than we are closer to remove that notice. It needs further review though, e.g. whether handling of .mill-version and .mill-jvm-opts works as expected. I doubt that, but can't say for sure. A minimal acceptable coursier-installed app should at least detect and warn in situations where the running version is different than requested by .mill-version or $MILL_VERSION and/or when it's not using the requested options.

alexarchambault added a commit to alexarchambault/scala-cli that referenced this pull request Aug 22, 2022
Taking into account com-lihaoyi/mill#1729 in particular (single
entrypoint).
@alexarchambault
Copy link
Contributor

It needs further review though, e.g. whether handling of .mill-version and .mill-jvm-opts works as expected. I doubt that, but can't say for sure. A minimal acceptable coursier-installed app should at least detect and warn in situations where the running version is different than requested by .mill-version or $MILL_VERSION and/or when it's not using the requested options.

It doesn't for now. cs launch mill:X.Y.Z basically launches Mill version X.Y.Z. This doesn't read .mill-version. coursier/apps#166 should make it read .mill-jvm-opts.

@lefou
Copy link
Member Author

lefou commented Aug 22, 2022

It needs further review though, e.g. whether handling of .mill-version and .mill-jvm-opts works as expected. I doubt that, but can't say for sure. A minimal acceptable coursier-installed app should at least detect and warn in situations where the running version is different than requested by .mill-version or $MILL_VERSION and/or when it's not using the requested options.

It doesn't for now. cs launch mill:X.Y.Z basically launches Mill version X.Y.Z. This doesn't read .mill-version. coursier/apps#166 should make it read .mill-jvm-opts.

I think coursier/apps#166 is not doing the right thing. The properties are not meant to be loaded by the Mill client JVM.

Mill client automatically loads the properties file to start the server process. But in case we don't want a server (e.g. options -i or --no-server), the JVM needs to run with these options. After reviewing the startup process in main branch, Mill already detects cases, when the options where not applied, and just starts a new JVM. This can be slower and inefficient, but should be enough for coursier.

IsolatedMillMainLoader.runMain(args);

if (!MillEnv.millJvmOptsAlreadyApplied() && MillEnv.millJvmOptsFile().exists()) {

alexarchambault added a commit to VirtusLab/scala-cli that referenced this pull request Aug 22, 2022
Taking into account com-lihaoyi/mill#1729 in particular (single
entrypoint).
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.

4 participants