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

Make window size configurable. #1210

Merged
merged 6 commits into from
May 5, 2017

Conversation

MakMukhi
Copy link
Contributor

No description provided.

clientconn.go Outdated
@@ -106,6 +106,20 @@ const defaultClientMaxMsgSize = math.MaxInt32
// DialOption configures how we set up the connection.
type DialOption func(*dialOptions)

// WithInitialWindowSize returns a DialOption which sets the value for initial window size on a stream.
func WithInitialWindowSize(s int32) DialOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

should the custom intitialConnWindowSize and InitialWindowSize should be capped to something smaller, and lower-bounded to current values here?

@@ -142,16 +145,24 @@ func newHTTP2Server(conn net.Conn, config *ServerConfig) (_ ServerTransport, err
Val: maxStreams,
})
}
if initialWindowSize != defaultWindowSize {
iwz := int32(initialWindowSize)
if config.InitialWindowSize >= defaultWindowSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like iwz should be reset to the custom value only if config.InitialWindowSize >= initialWindowSize, rather than the defaultWindowSize, since defaultWindowSize could potentially be less than initialWindowSize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The send quota on both client and server for both stream and connection takes the default value of defaultWindowSize. Therefore, that can be our lower cap. Is there an issue if it's smaller than initialWindowSize?

iwz = config.InitialWindowSize
}
icwz := int32(initialConnWindowSize)
if config.InitialConnWindowSize >= defaultWindowSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

since currently connection window is initialConnWindowSize, should icwz should be reset only if custom value is greater than initialConnWindowSize, to keep the current value as the lower limit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving as is following offline discussion.

idle: time.Now(),
kep: kep,
initialWindowSize: iwz,
initialConnWindowSize: icwz,
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like after their inFlows are created and the connection window updates sent, the initialConnWindowSize fields are no longer used by the transport structs, can they be gotten rid of as fields in the structs?

numOfIter := 11
// Set message size to exhaust largest of window sizes.
messageSize := max(max(wc.serverStream, wc.serverConn), max(wc.clientStream, wc.clientConn)) / int32(numOfIter-1)
messageSize = max(messageSize, 64*1024)
Copy link
Contributor

@apolcyn apolcyn Apr 29, 2017

Choose a reason for hiding this comment

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

s/max/min here?

Copy link
Contributor

Choose a reason for hiding this comment

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

scratched above comment

Copy link
Contributor

@apolcyn apolcyn left a comment

Choose a reason for hiding this comment

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

comments on a test that I think can be addressed in a follow up.

otherwise lgtm

defer server.stop()
defer client.Close()
// Sleep for a second to make sure connection is established.
time.Sleep(time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional nit, I think this can be done in a follow-up:
maybe this time.Sleep can be replaced with internal access to settings frame sends and acks - then this could wait on a settings frame acks. (It looks like it risks flakiness as is).

t.Fatalf("Client stream flow control window size is %v, want %v", cstream.fc.limit, connectOptions.InitialWindowSize)
}
// Sleep for a bit to make sure server received headers for the stream.
time.Sleep(time.Millisecond * 500)
Copy link
Contributor

Choose a reason for hiding this comment

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

related to comment above, maybe this sleep can be replaced by starting an RPC and then waiting for something on the server to make sure it's been started.

defer st.mu.Unlock()
return len(st.activeStreams) == 0
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still think there should be a time.Sleep(time.Second) here since there's really no good way of knowing that settings received were applied.
Can't check if streamSendQuota on transport was updated since in case of the second test that remains at the default size.
This seems flakier than before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I can't see any way myself to avoid the race/sleep without something "testonly".
My idea for it could be something like:
Maybe the handler that apply's settings could notify a test-only "settings applied" channel, or the same thing could be done with the "settings ack" handler in the client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, if we introduce call back hooks in the code we can get this done. However, I don't feel very comfortable with introducing test-facilitating code in our codebase, especially for a small test like this. What do you think?

@apolcyn
Copy link
Contributor

apolcyn commented May 3, 2017

lgtm on latest update!

@MakMukhi MakMukhi merged commit f3b5bf5 into grpc:master May 5, 2017
@menghanl menghanl added 1.4 Type: Feature New features or improvements in behavior Type: Performance Performance improvements (CPU, network, memory, etc) and removed Type: Feature New features or improvements in behavior labels Jun 7, 2017
@MakMukhi MakMukhi deleted the configurable_window_size branch May 4, 2018 02:01
@lock lock bot locked as resolved and limited conversation to collaborators Oct 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Performance Performance improvements (CPU, network, memory, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants