coc-julia icon indicating copy to clipboard operation
coc-julia copied to clipboard

Reduce time to first action by adding precompile execution file

Open lassepe opened this issue 3 years ago • 11 comments

It seems that currently, coc-julia only precompiles the package using statement but does not include any precompilation for any code actions such as formatting, "go to definition", or refactoring. However, the compile_env already supports this by setting an exec_files list. It would be nice to have an exec file by default as this should speed up the time to first action substantially.

lassepe avatar Jun 05 '22 11:06 lassepe

Technically, this kind of default_exec_file could also be executed as part of an "integration test" for this repo by the CI.

lassepe avatar Jun 05 '22 12:06 lassepe

have an exec file by default

Hello @lassepe, can you clear me for this default exec files?

fannheyward avatar Jun 16 '22 09:06 fannheyward

Sorry, that formulation was probably a bit cryptic. What I meant to suggest is to make use of the precompile_executiojn_file keyword argument of PackageCompiler.create_sysimage. You can find an example of its use here.

Ideally, one could allow the user to provide an execution file upon invocation of CocCommand julia.CompileLanguageServerSysimg <user-provided exec file>. At the same time, it would be nice to have a non-empty default execution file shipped together with coc-julia which contains a basic workload. This default file would be used as a representative workload to generate precompile statements for the event that the user does not specify any file.

lassepe avatar Jun 16 '22 11:06 lassepe

@lassepe try https://github.com/fannheyward/coc-julia/pull/325, now you can :CocCommand julia.CompileLanguageServerSysimg <user-provided exec file>.

have a non-empty default execution file shipped

Any suggestions about this?

fannheyward avatar Jun 16 '22 11:06 fannheyward

I'm not sure how one can programmatically trigger the LanguageServer actions (though of course it should be possible). For the JuliaFormatter component, for example, you can just run JuliaFormatter.format(".") to trigger formatting on the current directory. This way, create_sysimage will also compile the code for formatting. I've tested it locally and time-to-first-format is much lower now.

lassepe avatar Jun 16 '22 11:06 lassepe

Maybe it would also be possible to just execution the integration/unit tests of LanguageServer.jl to generate the precompile statements.

lassepe avatar Jun 16 '22 11:06 lassepe

using JuliaFormatter;
format_text("");

Tested create_sysimage with this file, and the formatting function works much faster for the first-format.

But for LanguageServer, didn't find any exec by now.

fannheyward avatar Jun 20 '22 13:06 fannheyward

This is probably a good question to ask the VS code folks over at the Julia Slack channel. I think they should already have this kind of workflow for the vscode extension. At least I was under the impression that they ship a system image somehow.

lassepe avatar Jun 20 '22 14:06 lassepe

I briefly talked to Sebastian from the LanguageServer.jl team and he says they don't ship a system image (or build on by default) because of the size restrictions in the VS Code market place. However, I think one good way of generating some useful precompile statements for LanguageServer.jl may be to run their package tests.

lassepe avatar Aug 12 '22 13:08 lassepe

We have run their tests before 0bcb405ca4efd3844d172a5516765422d0bbc84d, but it's removed due to #184. It seems works well now, but it increase the compile time significantly (The full tests of LanguageServer.jl cause 15 min on my m1 mac).

wangl-cc avatar Aug 19 '22 05:08 wangl-cc

I think 15min compilation would still be fine if afterwards the interaction with the language server is more responsive. Otherwise, this could also be am option for the CompileLanguageServerSyimg command

lassepe avatar Sep 02 '22 08:09 lassepe

coc-julia v0.13.0 will run exec.jl with Pkg.test("LanguageServer") and JuliaFormatter.format(@__FILE__) to precompile.

fannheyward avatar Oct 04 '22 06:10 fannheyward