techee / geany-lsp

LSP plugin for the Geany editor
GNU General Public License v2.0
19 stars 1 forks source link

Pylsp freeze (autocompletion) #51

Closed Johnmcenroyy closed 2 months ago

Johnmcenroyy commented 2 months ago

Hi, @techee Thank you very much for such a great work. It is really epic addition to Geany.

I am testing now in latest Geany and Geany Plugins compiled from Git in Arch Linux, also have made simple PKGBUILD for geany-lsp plugin. I have tested such lsp servers as: bash-language-server, lua-language-server, jedi-language-server, ruff server (NOT ruff-lsp which will be deprecated), pylsp, pyright. Didn't found any problems with any, except pylsp autocompletion (uses jedi). It freezes (cpu goes high and after some minutes autocompletion works again) after deletion autocompletion and beginning again. There is no problem with pylsp in Kate, also there is no problem with jedi-language-server in Geany.

Here is how it looks with pylsp (uses jedi for autocompletion): geany_pylsp

And this is with jedi-language-server geany-jedi-lsp

Regards

techee commented 2 months ago

@Johnmcenroyy Thanks for testing - I'm definitely interested in all the bugs you find.

As I understand it, it's the LSP server that freezes (and consumes high amount of CPU), not Geany, right? It would be best if you could disable all the other LSP features in the config file for the Python server to be sure it's autocompletion that causes the problems. Namely, set:

[Python]
...
diagnostics_enable=false
signature_enable=false
semantic_tokens_enable=false
highlighting_enable=false
code_lens_enable=false

# add also this for logging
rpc_log=stdout

When you enable logging, start Geany from the command-line and in the terminal window you should see the communication between the client and the server - apart from some document synchronization messages, you should see the autocompletion requests together with responses from the server - check if the server really gets stuck on some of the autocompletion requests and doesn't return anything for it. You can also try to enable rpc_log_full=true but the output might be too verbose.

Johnmcenroyy commented 2 months ago

@techee I have tested by enabling one by one and found that freeze of pylsp server happened when highlighting_enable=true Here is a log (3 minutes from freeze to autocompletion):

[13:27:25.375] C <-- S  resp:  textDocument/documentHighlight (5596 ms)
[13:27:25.912] C <-- S  notif: textDocument/publishDiagnostics
[13:27:28.087] C <-- S  resp:  textDocument/documentHighlight (8256 ms)
[13:27:28.628] C <-- S  notif: textDocument/publishDiagnostics
[13:27:30.894] C <-- S  resp:  textDocument/documentHighlight (11014 ms)
[13:27:31.431] C <-- S  notif: textDocument/publishDiagnostics
[13:27:33.668] C <-- S  resp:  textDocument/documentHighlight (13738 ms)
[13:27:34.206] C <-- S  notif: textDocument/publishDiagnostics
[13:27:36.551] C <-- S  resp:  textDocument/documentHighlight (16571 ms)
[13:27:37.087] C <-- S  notif: textDocument/publishDiagnostics
[13:27:39.237] C <-- S  resp:  textDocument/documentHighlight (19208 ms)
[13:27:39.772] C <-- S  notif: textDocument/publishDiagnostics
[13:27:42.094] C <-- S  resp:  textDocument/documentHighlight (22015 ms)
[13:27:42.630] C <-- S  notif: textDocument/publishDiagnostics
[13:27:44.796] C <-- S  resp:  textDocument/documentHighlight (24668 ms)
[13:27:45.333] C <-- S  notif: textDocument/publishDiagnostics
[13:27:47.528] C <-- S  resp:  textDocument/documentHighlight (27349 ms)
[13:27:48.066] C <-- S  notif: textDocument/publishDiagnostics
[13:27:50.239] C <-- S  resp:  textDocument/documentHighlight (30009 ms)
[13:27:50.775] C <-- S  notif: textDocument/publishDiagnostics
[13:27:53.073] C <-- S  resp:  textDocument/documentHighlight (32793 ms)
[13:27:53.096] C <-- S  resp:  textDocument/documentHighlight (32765 ms)
[13:27:53.118] C <-- S  resp:  textDocument/documentHighlight (32737 ms)
[13:27:53.654] C <-- S  notif: textDocument/publishDiagnostics
[13:27:59.329] C <-- S  resp:  textDocument/documentHighlight (38848 ms)
[13:27:59.931] C <-- S  notif: textDocument/publishDiagnostics
[13:28:07.944] C <-- S  resp:  textDocument/documentHighlight (47412 ms)
[13:28:08.546] C <-- S  notif: textDocument/publishDiagnostics
[13:28:16.602] C <-- S  resp:  textDocument/documentHighlight (56020 ms)
[13:28:17.214] C <-- S  notif: textDocument/publishDiagnostics
[13:28:25.143] C <-- S  resp:  textDocument/documentHighlight (64511 ms)
[13:28:25.747] C <-- S  notif: textDocument/publishDiagnostics
[13:28:33.753] C <-- S  resp:  textDocument/documentHighlight (73070 ms)
[13:28:34.355] C <-- S  notif: textDocument/publishDiagnostics
[13:28:42.298] C <-- S  resp:  textDocument/documentHighlight (81565 ms)
[13:28:42.901] C <-- S  notif: textDocument/publishDiagnostics
[13:28:50.864] C <-- S  resp:  textDocument/documentHighlight (90082 ms)
[13:28:51.466] C <-- S  notif: textDocument/publishDiagnostics
[13:28:59.404] C <-- S  resp:  textDocument/documentHighlight (98572 ms)
[13:29:00.007] C <-- S  notif: textDocument/publishDiagnostics
[13:29:07.562] C <-- S  resp:  textDocument/documentHighlight (106679 ms)
[13:29:08.100] C <-- S  notif: textDocument/publishDiagnostics
[13:29:10.445] C <-- S  resp:  textDocument/documentHighlight (109511 ms)
[13:29:10.982] C <-- S  notif: textDocument/publishDiagnostics
[13:29:13.247] C <-- S  resp:  textDocument/documentHighlight (112264 ms)
[13:29:13.784] C <-- S  notif: textDocument/publishDiagnostics
[13:29:16.116] C <-- S  resp:  textDocument/documentHighlight (115083 ms)
[13:29:16.653] C <-- S  notif: textDocument/publishDiagnostics
[13:29:18.955] C <-- S  resp:  textDocument/documentHighlight (117871 ms)
[13:29:19.492] C <-- S  notif: textDocument/publishDiagnostics
[13:29:21.779] C <-- S  resp:  textDocument/documentHighlight (120645 ms)
[13:29:21.781] C <-- S  resp:  textDocument/documentHighlight (120598 ms)
[13:29:21.799] C <-- S  resp:  textDocument/documentHighlight (120565 ms)
[13:29:22.336] C <-- S  notif: textDocument/publishDiagnostics
[13:29:24.662] C <-- S  resp:  textDocument/documentHighlight (123328 ms)
[13:29:25.199] C <-- S  notif: textDocument/publishDiagnostics
[13:29:27.303] C <-- S  resp:  textDocument/documentHighlight (125920 ms)
[13:29:27.839] C <-- S  notif: textDocument/publishDiagnostics
[13:29:30.239] C <-- S  resp:  textDocument/documentHighlight (128806 ms)
[13:29:30.775] C <-- S  notif: textDocument/publishDiagnostics
[13:29:33.033] C <-- S  resp:  textDocument/documentHighlight (131549 ms)
[13:29:33.569] C <-- S  notif: textDocument/publishDiagnostics
[13:29:35.832] C <-- S  resp:  textDocument/documentHighlight (134298 ms)
[13:29:36.369] C <-- S  notif: textDocument/publishDiagnostics
[13:29:38.672] C <-- S  resp:  textDocument/documentHighlight (137090 ms)
[13:29:39.300] C <-- S  notif: textDocument/publishDiagnostics
[13:29:47.262] C <-- S  resp:  textDocument/documentHighlight (145629 ms)
[13:29:47.866] C <-- S  notif: textDocument/publishDiagnostics
[13:29:55.763] C <-- S  resp:  textDocument/documentHighlight (154079 ms)
[13:29:56.366] C <-- S  notif: textDocument/publishDiagnostics
[13:30:04.343] C <-- S  resp:  textDocument/documentHighlight (162608 ms)
[13:30:04.945] C <-- S  notif: textDocument/publishDiagnostics
[13:30:13.030] C <-- S  resp:  textDocument/documentHighlight (171090 ms)
[13:30:13.634] C <-- S  notif: textDocument/publishDiagnostics
[13:30:21.573] C <-- S  resp:  textDocument/documentHighlight (179431 ms)
[13:30:21.597] C <-- S  resp:  textDocument/documentHighlight (179302 ms)
[13:30:21.620] C <-- S  resp:  textDocument/documentHighlight (179190 ms)
[13:30:21.638] C <-- S  resp:  textDocument/documentHighlight (178856 ms)

With highlighting_enable=false all works well, operations usually take 2-5ms and up to 200ms for completion.

techee commented 2 months ago

Thanks - it looks pylsp doesn't like too frequent calls of documentHighlight which were really sent too frequently by the plugin.

I've just pushed a change that tries to address this:

  1. For normal edits (typing, backspace), the request isn't sent at all
  2. When moving cursor e.g. using arrows, the request is sent in at most 300ms intervals

Please give this a try if it fixes the issue for you.

Johnmcenroyy commented 2 months ago

@techee Thank you very much. All works perfectly, very fast.