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

Use Kakoune's socket to send commands instead of kak -p. #553

Open
tadeokondrak opened this issue Nov 1, 2021 · 3 comments
Open

Use Kakoune's socket to send commands instead of kak -p. #553

tadeokondrak opened this issue Nov 1, 2021 · 3 comments

Comments

@tadeokondrak
Copy link
Contributor

There is a noticeable lag when using #545 on a project with a few hundred crate dependencies just to show the progress bar when rust-analyzer is sending updates very fast. I'm not sure where it comes from.

It occurred to me that this might come from this code:
https://github.com/kak-lsp/kak-lsp/blob/23c5f3c450c1e42856c7ff15af4234d566ee5b11/src/editor_transport.rs#L57-L62

Instead of using kak -p, we can use the remote socket at $XDG_RUNTIME_DIR/kakoune/$pid. This allows us to have a persistent connection up, so we don't need to make a new process every time we send a command.

I believe the protocol is just a 0x02 byte, followed by a 32-bit size, followed by the string. Because there's probably no stability guarantee, this could be an optional setting - if it ends up speeding anything up at all.

I will probably try this out soon and see if there's any performance improvement.

@caksoylar
Copy link
Contributor

I use this approach in kakoune-smooth-scroll (relevant code here to discover the socket path and construct the message). Like you also noted, my understanding is that this is an internal API so it is subject to change, but in practice I only had to update it once so far due to a socket location tweak in Kakoune.

This approach indeed buys a decent amount of time on systems where process invocation is slow, like Cygwin/MSYS or when network filesystems are involved.

@krobelus
Copy link
Member

krobelus commented Nov 4, 2021

an option sounds reasonable but we should confirm that it makes a difference.
Maybe we can also add some profiling tool to find performance problems.
On my system echo nop | kak -p somesession takes 4-8 milliseconds.

@krobelus
Copy link
Member

There is a noticeable lag when using #545 on a project with a few hundred crate dependencies just to show the progress bar when rust-analyzer is sending updates very fast. I'm not sure where it comes from.

I think this has been fixed by c32aa61 (lsp-handle-progress: forward at most one progress update per second, 2022-10-18).

Regardless, I think it'd be a good idea to use the socket, shouldn't be too much work.
The other direction is trickier: when sending from editor to kak-lsp, we can't really avoid a shell + kak-lsp process unless we cut down on usability (automatic restarts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants