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

Increase buffer sizes #4426

Closed
bt90 opened this issue Apr 11, 2024 · 5 comments · Fixed by #4455
Closed

Increase buffer sizes #4426

bt90 opened this issue Apr 11, 2024 · 5 comments · Fixed by #4455
Milestone

Comments

@bt90
Copy link
Contributor

bt90 commented Apr 11, 2024

This topic came up in the Syncthing forum: https://forum.syncthing.net/t/system-is-slow-on-windows-look-here/21925

I'm unsure if users really need to modify the registry or if the socket options are enough to tune the buffer sizes. After briefly skimming the code, I couldn't spot where we do this for Windows?

@marten-seemann
Copy link
Member

It's done here: https://github.com/quic-go/quic-go/blob/master/sys_conn_buffers.go

Not sure how / if it works on Windows. Would be great if you could try it out.

@bt90
Copy link
Contributor Author

bt90 commented Apr 11, 2024

wireguard-go seems to directly set the socket options:

https://github.com/WireGuard/wireguard-go/blob/master/conn/controlfns_windows.go

No idea if that's necessary, though.

Would be great if you could try it out.

Can I evaluate this using Syncthing?

@marten-seemann
Copy link
Member

This function is used to check the size of the buffer:

func inspectReadBuffer(c syscall.RawConn) (int, error) {
var size int
var serr error
if err := c.Control(func(fd uintptr) {
size, serr = windows.GetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_RCVBUF)
}); err != nil {
return 0, err
}
return size, serr
}

You could add some logging before and after we increase the buffer, and see if the value changes.

@bt90
Copy link
Contributor Author

bt90 commented Apr 12, 2024

Judging from the debug logging, things are working as expected:

2024/04/12 17:06:34 Increased receive buffer size to 2048 kiB
2024/04/12 17:06:34 Increased send buffer size to 2048 kiB
2024/04/12 17:06:34 Setting DF for IPv4 and IPv6.
2024/04/12 17:06:34 server Listening for udp connections on [::]:22000

Simply tested via

set QUIC_GO_LOG_LEVEL=debug
.\syncthing.exe

I suspect that the speedup observed by our forum user was due to the obscenely high default buffer size of 25MB. While this is obviously too much, should we follow wireguard-go and increase our buffer to 7MB? See this commit message for more details: WireGuard/wireguard-go@f26efb6

Edit: tested with the AFD registry parameters (25MB) in place:

2024/04/12 17:16:57 Conn has receive buffer of 24414 kiB (wanted: at least 2048 kiB)
2024/04/12 17:16:57 Conn has send buffer of 24414 kiB (wanted: at least 2048 kiB)
2024/04/12 17:16:57 Setting DF for IPv4 and IPv6.
2024/04/12 17:16:57 server Listening for udp connections on [::]:22000

@marten-seemann
Copy link
Member

I suspect that the speedup observed by our forum user was due to the obscenely high default buffer size of 25MB. While this is obviously too much, should we follow wireguard-go and increase our buffer to 7MB? See this commit message for more details: WireGuard/wireguard-go@f26efb6

Sounds reasonable. Want to create a PR?

@marten-seemann marten-seemann changed the title Increase buffer sizes on Windows Increase buffer sizes Apr 19, 2024
@marten-seemann marten-seemann added this to the v0.43 milestone Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants