lite-xl / lite-xl-lsp

LSP Plugin for Lite XL editor
MIT License
160 stars 21 forks source link

[Bug] High CPU usage when moving mouse around #75

Closed ghost closed 1 year ago

ghost commented 1 year ago

As the title says, Lite-XL's CPU usage spikes when I wiggle my mouse around, both in the code section aswell as in the UI itself.

I have tested it with all plugins disabled (except for the lsp one), as well as with an empty configuration.

It does NOT occur when the mouse is completely still, it only occurs when the mouse is moving around.

It ONLY occurs when the lsp plugin has been loaded, and not with any other plugin

System and env info:

My config can be found here

ghost commented 1 year ago

After setting config.plugins.lsp.mouse_hover to false, the problem is gone, so it has something to do with the symbol hovering info

ghost commented 1 year ago

On every mouse move, this function gets invoked: https://github.com/lite-xl/lite-xl-lsp/blob/1eb5b431f91333650c35a04bc386a3b621235f2e/init.lua#L2314

Somewhere in there is the culprit

jgmdev commented 1 year ago

By the way I posted on the wrong issue before... Should have posted on this one.

Guldoman commented 1 year ago

Can confirm, I think I only tested the latest changes on Lite XL master where it works fine. Will investigate.

From the other issue:

This other repo takes a more basic approach to hovering that doesn't involves the tokenizer...

The approach here involves the tokenizer only after the mouse stopped moving, or while the trigger is active only until the mouse is out of the token. Also considering that the tokenizer caches the results that are already on screen...

ghost commented 1 year ago

Just tested it again using the master branch, and this time getting a different error (but no CPU spike)!: 2023-11-06-205919_806x185_scrot

Guldoman commented 1 year ago

Could you check if #77 fixes both this and #76 for you?

Just tested it again using the master branch, and this time getting a different error (but no CPU spike)!: 2023-11-06-205919_806x185_scrot

Could you open a separate issue about this?

ghost commented 1 year ago

I can't test if that pull fixes the issues because it'll result in the error I just opened the issue for

Guldoman commented 1 year ago

Let me know if you test with #77 (and #79 if needed) applied.

ghost commented 1 year ago

Tested with #77 and #79, and the CPU usage only increases a tiny bit (goes to ~25% of a single core).