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

Why is UDPSession.SetWriteBuffer no effect if accepted from Listener? #226

Open
zhiqiangxu opened this issue Jul 5, 2022 · 2 comments
Open

Comments

@zhiqiangxu
Copy link

zhiqiangxu commented Jul 5, 2022

// SetWriteBuffer sets the socket write buffer, no effect if it's accepted from Listener
func (s *UDPSession) SetWriteBuffer(bytes int) error {
	s.mu.Lock()
	defer s.mu.Unlock()
	if s.l == nil {
		if nc, ok := s.conn.(setWriteBuffer); ok {
			return nc.SetWriteBuffer(bytes)
		}
	}
	return errInvalidOperation
}

If UDPSession said to be a drop-in replacement for net.TCPConn, why is UDPSession.SetWriteBuffer no effect if accepted from Listener?

@xtaci
Copy link
Owner

xtaci commented Jul 5, 2022

because we only have one shared socket for UDP

@zhiqiangxu
Copy link
Author

zhiqiangxu commented Jul 5, 2022

image

Today I made a test to compare the performance of quic/tcp/ws/http/grpc/kcp(this is the order of testcases, not the order of performance), each test sends and receives 100,000 requests/responses, all other logic is the same(they all fit into the qrpc framework), the only difference is how the raw bytes are read(each implementing net.Conn in its own way), as you can see in the above picture, it turns out kcp is the slowest. And there's a warning saying that calling SetWriteBuffer on a Accepted UDPSession is invalid operation.

The testcase for kcp is this one:https://github.com/zhiqiangxu/qrpc/blob/quic_and_kcp/test/qrpc_kcp_test.go#L80

After I tuned kcp.ListenWithOptions(address, nil, 0, 0) to kcp.ListenWithOptions(address, nil, 7, 3) in this commit, it still takes more than 6 seconds to finish all 100,000 requests/responses, slower than plain http.

Any advice is very appreciated!

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

2 participants