After a conversation on Slack, with Tom McLaughlin, I decided to try adding some precompilation to LanguageServer.jl. Tom had noticed about 10 second lag in the execution of LanguageServer.runserver()
. This is part of julia-vscode, so a speed up here would be quite beneficial.
Before the change, runserver()
would take about 14 seconds to compile on my computer after each time the package is loaded.
julia> @time runserver()
...
30.517983 seconds (6.45 M allocations: 370.912 MiB, 1.60% gc time, 46.59% compilation time)
julia> 30.517983*0.4659
14.2183282797
After the change, runserver()
, compilation takes 1.4 seconds.
julia> @time runserver()
...
10.929685 seconds (3.77 M allocations: 198.920 MiB, 3.33% gc time, 12.61% compilation time)
julia> 10.929685 * 0.1261
1.3782332784999998
Load time while running using LanguageServer
increased from ~20 ms to ~550 ms. The compiled cache shared library went from 2.4 MB to 13 MB.
The substantive part of my change is as follows. Can you do better?
using PrecompileTools
...
@setup_workload begin
iob = IOBuffer()
println(iob)
@compile_workload begin
runserver(iob)
end
end
precompile(runserver, ())
There’s a lot to improve. Running this during precompilation involves network activity for one.
Here’s the pull request:
In case you missed the announcement, PrecompileTools.jl is the new name of SnoopPrecompile.jl.