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

Slow yank/paste, even when not using system clipboard #18

Open
jlc-backsbag opened this issue Feb 20, 2023 · 3 comments
Open

Slow yank/paste, even when not using system clipboard #18

jlc-backsbag opened this issue Feb 20, 2023 · 3 comments

Comments

@jlc-backsbag
Copy link

After installing and using win32yank as the clipboard program in neovim, yanking and pasting have become really slow (~0.5s). This happens even when not using the system clipboard (yanking using just y not "_y.

Is there a way to at least remove the delay when yanking to vim-specific registers?

@TaylorTrz
Copy link

Same to me...

It takes 709 ms to yank to system clip board. Maybe it there a good way to faster this?

example:

$ start=$[$(date +%s%N)/1000000] && echo "abc" | win32yank.exe -i  && end=$[$(date +%s%N)/1000000] && echo `expr $end - $start`
709

@equalsraf
Copy link
Owner

Hard to be sure, since there is some locking involved. For anecdotal evidence I wrote a couple of tests here to measure time

  • get_clipboard() took between 38-60μs
  • set_clipboard() took at most 77-430μs

Time measurements were done by wrapping the calls with std Duration elapsed(), and I'm using debug builds here. Bottom line being that the api calls themselves do not seem to be the problem.

Maybe the delay comes from process execution.
For total time I'm using powershell's measure-command

Measure-Command { echo "abc" | .\target\debug\win32yank -i }

and my times ranged from 25 to 33ms. Still much lower that in your case.

@TaylorTrz is this example being executed from wsl or something? that syntax looks very sh-ish. If so, maybe the time would provide more details.

This happens even when not using the system clipboard (yanking using just y not "_y.

This one is surprising. I would not expect this unless using set clipboard=unnamedplus or similar caused it to always use the clipboard.

@TaylorTrz
Copy link

TaylorTrz commented Mar 20, 2023

@equalsraf Wells, Thanks to your kindly reply.

I do this time cost test from Window Subsystem on Linux (WSL v2.0) , and the average time i test today is
80ms.

Then I tried to use strace to run this, the syscall:

$  echo "abc" | strace -tt win32yank.exe -i
13:07:42.970990 execve("/usr/local/bin/win32yank.exe", ["win32yank.exe", "-i"], 0x7ffe20590130 /* 31 vars */) = 0
13:07:42.977774 socket(AF_VSOCK, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3
13:07:42.981332 accept4(3, {sa_family=AF_VSOCK, sa_data="\0\0\335\223-\221\2\0\0\0\0\0\0\0"}, [16], SOCK_CLOEXEC) = 5
13:07:43.071391 close(5)                = 0
13:07:43.073073 +++ exited with 0 +++

So, the time mostly costed by socket poll and recvfrom (AF_VSOCK). I think the average time less than 100ms is good enough for yank/paste.

strace.log

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