jstarks / npiperelay

npiperelay allows you to access Windows named pipes from WSL
MIT License
660 stars 71 forks source link

Very slow on Windows 11? #26

Closed mendhak closed 2 years ago

mendhak commented 2 years ago

Is anyone experiencing slowness issues on Windows 11?

I'm using this from WSL2 to connect to the OpenSSH Agent, like so

# KeepassXC as SSH agent
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock

ss -a | grep -q $SSH_AUTH_SOCK
if [ $? -ne 0 ]; then
    rm -f $SSH_AUTH_SOCK
    (setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$HOME/npiperelay/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork &) >/dev/null 2>&1
fi

And it works, but it takes about 25-30 seconds for any SSH or Git-over-SSH operations.

I even tried a straight up, direct call to it.

time $HOME/npiperelay/npiperelay.exe --help

And that took 25 seconds. Everything else in the WSL2 is fast, no slowdowns that I can see, so I think it's just this npiperelay. I've tried building it via go, and also getting it from the Releases of this repo, same problem.

I'm not famliar with ss, or socat or nipiperelay so I'm not sure how to troubleshoot this or figure out what's going wrong.

a-m-s commented 2 years ago

Have you followed the instructions to put the binary in the Windows file system with a soft-link from Linux? I too observed a delay of a few seconds when I tried to run it in the Linux file system, but that's Windows 10 so it might be different.

mendhak commented 2 years ago

Thank you so much! You're right, that made a huge difference. And the README even calls me out on it 😀

You may be tempted to just put the real binary directly into /usr/local/bin, but this will not work because Windows currently cannot run binaries that exist in the Linux namespace -- they have to reside somewhere under the Windows portion of the file system.

So it was working for me somehow, fine in Win10, but very slowly in Win11. As a test, I moved the .exe to C:/Temp and created a symlink,

sudo ln -s /c/Temp/npiperelay.exe /usr/local/bin/npiperelay.exe

Then in my .bashrc

# KeepassXC as SSH agent
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock

ss -a | grep -q $SSH_AUTH_SOCK
if [ $? -ne 0 ]; then
    rm -f $SSH_AUTH_SOCK
    (setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"/usr/local/bin/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent>fi

Yep it's back to regular speeds. Thanks so much @a-m-s even if it was super obvious!