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 UDP receive buffer size #2791

Merged
merged 1 commit into from
Oct 19, 2020
Merged

Conversation

marten-seemann
Copy link
Member

Fixes #2255. Ref #2586.

... and emit a log message if we can't do so.

}
size, err := inspectReadBuffer(c)
if err != nil {
log.Printf("Failed to determine receive buffer size: %s", err)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using log here, so that users will actually see the log message (even if QUIC_GO_LOG_LEVEL is not set).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this always need to log? What are the failure modes here that require user action?

We support custom pconns, which don't need to implement SyscallConn(), and could benignly trigger this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do, but I'm assuming that all pconns at some point wrap a UDP conn. QUIC v1 is only defined to work over UDP anyway.

@codecov
Copy link

codecov bot commented Sep 16, 2020

Codecov Report

Merging #2791 into master will decrease coverage by 0.14%.
The diff coverage is 55.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2791      +/-   ##
==========================================
- Coverage   85.96%   85.83%   -0.14%     
==========================================
  Files         133      134       +1     
  Lines        8990     9030      +40     
==========================================
+ Hits         7728     7750      +22     
- Misses        928      939      +11     
- Partials      334      341       +7     
Impacted Files Coverage Δ
packet_handler_map.go 74.18% <52.00%> (-2.95%) ⬇️
conn_notwindows.go 57.14% <57.14%> (ø)
conn_windows.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51fd3c3...14a5aa8. Read the comment docs.

@@ -2,6 +2,9 @@ package protocol

import "time"

// DesiredReceiveBufferSize is the kernel UDP receive buffer size that we'd like to use.
const DesiredReceiveBufferSize = (1 << 20) * 2 // 2 MB
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is what we really need, we might need to adjust this constant after more extensive benchmarking.

}
size, err := inspectReadBuffer(c)
if err != nil {
log.Printf("Failed to determine receive buffer size: %s", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this always need to log? What are the failure modes here that require user action?

We support custom pconns, which don't need to implement SyscallConn(), and could benignly trigger this?

packet_handler_map.go Outdated Show resolved Hide resolved
@marten-seemann
Copy link
Member Author

Merging this PR for now. We can still change the log messages later, if they turn out to be too annoying.

@marten-seemann marten-seemann merged commit 4fc57c0 into master Oct 19, 2020
@marten-seemann marten-seemann deleted the udp-receive-buffer-size branch October 19, 2020 05:55
@@ -7,3 +7,7 @@ import "net"
func newConn(c net.PacketConn) (connection, error) {
return &basicConn{PacketConn: c}, nil
}

func inspectReadBuffer(net.PacketConn) (int, error) {
return 0, nil
Copy link

@dswarbrick dswarbrick Oct 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason why golang.org/x/sys wasn't used? GetsockoptInt should work for Windows in that package.

See https://go-review.googlesource.com/c/sys/+/233200

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dswarbrick Not sure I understand. Can you elaborate?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that the inspectReadBuffer function here is a no-op on Windows, presumably because syscall.GetsockoptInt in the standard library is not implemented for Windows:

func GetsockoptInt(fd Handle, level, opt int) (int, error) { return -1, EWINDOWS }

Since the syscall package is frozen, that functionality is not likely to make it into the standard library. However, it is implemented in the golang.org/x/sys/windows package, as described in the link I posted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dswarbrick Thanks for pointing this out, I wasn't aware of the syscall package being frozen.
Would you mind sending us a PR that adds this functionality on Windows?

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

Successfully merging this pull request may close these issues.

investigate modifying the kernel's receive buffer size
3 participants