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

Cut down initialization time for debugger (and server) #51

Open
hongyi-zhao opened this issue May 27, 2021 · 6 comments
Open

Cut down initialization time for debugger (and server) #51

hongyi-zhao opened this issue May 27, 2021 · 6 comments
Labels
long-run Works that will be done in the unforeseen future

Comments

@hongyi-zhao
Copy link

hongyi-zhao commented May 27, 2021

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:

image

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

@hongyi-zhao hongyi-zhao changed the title The first time running of the "Start Debugging F5" after login into the system will failed with "connect ECONNREFUSED". The first time running of the "Start Debugging F5" after logging into the system will failed with "connect ECONNREFUSED". May 27, 2021
@hongyi-zhao hongyi-zhao changed the title The first time running of the "Start Debugging F5" after logging into the system will failed with "connect ECONNREFUSED". After logging into the system, the first time running of the "Start Debugging F5" will failed with "connect ECONNREFUSED". May 27, 2021
@kenkangxgwe
Copy link
Owner

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.

@kenkangxgwe
Copy link
Owner

But indeed, if you press F5 immediately after the project is opened, it will give you ECONNREFUSED

@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 29, 2021

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.

@kenkangxgwe
Copy link
Owner

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.

@kenkangxgwe kenkangxgwe added the long-run Works that will be done in the unforeseen future label May 30, 2021
@kenkangxgwe kenkangxgwe changed the title After logging into the system, the first time running of the "Start Debugging F5" will failed with "connect ECONNREFUSED". Cut down initialization time for debugger (and server) May 30, 2021
@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 30, 2021

Please note the following conclusion which I've drawn previously:

The easy and quick way to fix this problem is running the math or mathematica commands once.

This method, especially starting the terminal version with the math command, only needs very short time to solve this problem.

@kenkangxgwe
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
long-run Works that will be done in the unforeseen future
Projects
None yet
Development

No branches or pull requests

2 participants