non-Jedi / eglot-jl

Wrapper for using Julia LanguageServer.jl with emacs eglot
Creative Commons Zero v1.0 Universal
62 stars 11 forks source link

Simplify/automate the compilation and use of a system image #12

Open ffevotte opened 4 years ago

ffevotte commented 4 years ago

The following PR introduces features helping compile and use custom system images for LanguageServer and SymbolServer. The expected benefits are reduced start-up times for the language server. On my (old-ish) machine, start-up times are reduced from 20 seconds to less than 2. On a newer machine where I also tested this, times went from 15 seconds down to less than 1.

The idea is the following:

This is what the first commit in this PR introduces, alongside with instructions in README.org explaining how to compile the system image, and set eglot-jl-julia-args to use it.

The second commit goes a step further: it automates the search for a suitable system image at server startup, in order to use it if one is found.

Additionally, a new autoloaded command allows running the system image generation script from within emacs. The same command could be used to re-generate a system image if the previous one caused problems for any reason.

This is documented in README.org. I've tested this with Julia 1.3 and 1.4, on Windows and Linux, without encountering any problem (I don't have access to a Mac).

I know you were reluctant to handle system images in eglot-jl, and were (rightfully) especially concerned about possible ways that a system image would become obsolete. I tried making this implementation as robust as possible, but I might very well have overlooked something. So please do not hesitate to tell me if something bothers you with this proposal.

non-Jedi commented 4 years ago

Could you rebase on master, and I'll try to review in the next few days?

ffevotte commented 4 years ago

OK, the PR is now rebased on the current master, and everything seems to work on my system.

There were several conflicts though; I'll try and test more in the coming days, and report back if anything goes wrong.

ffevotte commented 4 years ago

As always, thanks for your insightful comments, that are thought-provoking.

To sum everything up, my current position would be along the lines of:

What would you think about that?

non-Jedi commented 4 years ago

That sounds like a good path forward to me. :) I will note that if using the custom sysimage requires spawning multiple julia processes, it should definitely be opt-in rather than opt-out, but that's the plan anyway.

As an alternative, maybe eglot-jl-enable-sysimage could cause the sysimage to be compiled on eglot-jl-init so that compiling the sysimage doesn't run afoul of eglot-connect-timeout? Then invoking eglot either errors or shows a warning if the sysimage isn't available? We would want to make sure this is happening asynchronously of course.

non-Jedi commented 4 years ago

Related: https://github.com/JuliaLang/julia/pull/35794

ffevotte commented 4 years ago

I'v finally gotten around to working on this again. The latest commit should implement the strategy discussed above:


@non-Jedi When you have some time to look at this (no rush!), I'd love to hear what you think.

ffevotte commented 4 years ago

There is a small gotcha regarding the use of system images in conjunction with customized eglot-jl-language-server-project: although the Emacs side of the process knows which LanguageServer project should be activated, we currently don't forward that explicitly to Julia. And introspection capabilities have only been recently introduced in Pkg, so that for older Julia versions, there is no way (that I know of) of retrieving the currently active project in order to correctly encode the SHA1 of its Manifest in the sysimage name.

There are several ways of dealing with this that I can think of:

I think my preference goes to this last option, but I'd love to hear your thoughts about it if you have some...

ffevotte commented 4 years ago

I went ahead and fixed the issues with eglot-jl-language-server-project and eglot-jl-enable-sysimage being used together in the latest commit. I'm happy with this solution, since it does not affect eglot-jl.jl in any way for users not opting in the sysimage feature.

non-Jedi commented 3 years ago

I haven't had an opportunity to use Julia for a while to test-drive this, but at this point if you've been using this without issue, I'm fine with you merging it. Sorry for the extremely long review delay.

ffevotte commented 3 years ago

This new version is rebased on the current master. It also incorporates (minor) modifications related to the need to resolve environments when switching Julia version.

I'm planning to test this in daily life for a few days in order to check that nothing went wrong with those last changes.

chriselrod commented 1 year ago

This would still be nice to have IMO, even with the improvements in 1.9.