lsp-wl
lsp-wl copied to clipboard
Cut down initialization time for debugger (and server)
On Ubuntu 20.04, I use the latest stable vscode
and the git master version of lsp-wl
. I noticed the following strange problem: after login into the system, the first time running of the "Start Debugging F5" with the lsp-wl
will fail with the following error:
The easy and quick way to fix this problem is running the math
or mathematica
commands once. Other workarounds, based on my observation, including, but may not be limited to, the following way: Click on the "Cancel", and then re-run the "Start Debugging F5" for several times, the problem will finally disappear.
Afterwards, if I close the vscode
, then restart it, the problem doesn't appear again. More specifically, the problem occurs only when F5
is called from vscode
for the first time after logging into the system.
Regards, HY
Can you make sure that the language server itself is fully started before you press F5? It works w/o any problem on my side.
But indeed, if you press F5 immediately after the project is opened, it will give you ECONNREFUSED
It seems that the only Mathematica
process is shown below when the ECONNREFUSED
occurred:
werner@X10DAi:~$ ps -aux| grep Mathematica |grep -v grep
werner 1219502 56.0 0.0 4333932 224784 ? Rl 21:18 0:33 /opt/Wolfram/Mathematica/12.1/SystemFiles/Kernel/Binaries/Linux-x86-64/WolframKernel -script ~/Public/repo/github.com/kenkangxgwe/lsp-wl.git/init.wls --socket=6536 --clientProcessId=1218208
And, after the debug process started successfully, the Mathematica
processes will look like following:
werner@X10DAi:~$ ps -aux| grep Mathematica |grep -v grep
werner 1219502 48.3 0.0 4713876 251100 ? Rl 21:18 0:39 /opt/Wolfram/Mathematica/12.1/SystemFiles/Kernel/Binaries/Linux-x86-64/WolframKernel -script ~/Public/repo/github.com/kenkangxgwe/lsp-wl.git/init.wls --socket=6536 --clientProcessId=1218208
werner 1268623 10.4 0.0 1039668 150784 ? SNl 21:19 0:01 /opt/Wolfram/Mathematica/12.1/SystemFiles/Kernel/Binaries/Linux-x86-64/WolframKernel -subkernel -noinit -nopaclet -wstp -linkprotocol SharedMemory -linkconnect -linkname 2pk56_shm
So, it seems that the problem is caused by the slow initialization of the language server itself
when invoked from vscode
.
This might be (and should be) tolerated, because it takes some round trips for the server to communicate with the editor to start the debugger. Will look into refactorings to accelerate the initialization but not in high priority.
Please note the following conclusion which I've drawn previously:
The easy and quick way to fix this problem is running the
math
ormathematica
commands once.
This method, especially starting the terminal version with the math
command, only needs very short time to solve this problem.
I don't see why it is a fix, since invoking another process will take even longer time. According to my measures, the current initialization time for the server is ~3.47s. Opening the debug port adds ~0.02s while running the math
will add ~1.06s.