-
Notifications
You must be signed in to change notification settings - Fork 4.5k
grpc: introduce new DialOption and ServerOption to configure initial window size without disabling BDP estimation. #8283
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8283 +/- ##
==========================================
- Coverage 82.35% 82.17% -0.18%
==========================================
Files 419 419
Lines 42034 42073 +39
==========================================
- Hits 34615 34572 -43
- Misses 5968 6029 +61
- Partials 1451 1472 +21
🚀 New features to boost your workflow:
|
Is this the same as #8279? Should the original PR be closed? |
@dfawley Can you please review this when you get a chance? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR should implement just (1) from #7923.
It should not mark the old options as deprecated.
- Please improve the PR title ("the size"?)
- Please write release notes
Thanks!
@dfawley Could you please re-review this PR? I've made the changes also updated the PR title and added the release notes as suggested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And please update the first comment and release notes in this PR accordingly.
// TestJoinDialOption_StaticConnAndStreamWindowSizes verifies that both static | ||
// stream and connection window sizes set via joined dial options are correctly | ||
// applied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some special interaction here with these and Join? I don't think there's much need for this test, since it just tests Join
, but we already have a test for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
dialoptions.go
Outdated
// WithStaticStreamWindowSize returns a DialOption to set the static initial | ||
// stream window size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// WithStaticStreamWindowSize returns a DialOption to set the static initial | |
// stream window size. | |
// WithStaticStreamWindowSize returns a DialOption which sets the initial | |
// stream window size to the value provided and prevents dynamic flow control | |
// from adjusting it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
dialoptions.go
Outdated
// WithStaticStreamWindowSize returns a DialOption which sets the initial | ||
// stream window size to the value provided and prevents dynamic flow control | ||
// from adjusting it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// WithStaticStreamWindowSize returns a DialOption which sets the initial | |
// stream window size to the value provided and prevents dynamic flow control | |
// from adjusting it | |
// WithStaticStreamWindowSize returns a DialOption which sets the initial | |
// stream window size to the value provided and disables dynamic flow control. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
dialoptions.go
Outdated
// WithStaticConnWindowSize returns a DialOption which sets the initial | ||
// connection window size to the value provided and prevents dynamic flow control | ||
// from adjusting it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// WithStaticConnWindowSize returns a DialOption which sets the initial | |
// connection window size to the value provided and prevents dynamic flow control | |
// from adjusting it | |
// WithStaticConnWindowSize returns a DialOption which sets the initial | |
// connection window size to the value provided and disables dynamic flow control. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
internal/transport/transport.go
Outdated
// BdpEstimationEnabled controls whether dynamic window sizing is enabled. | ||
BdpEstimationEnabled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are adding this boolean, then you should leave the names of the other fields as Initial
. This boolean will now determine whether they are initial or static. I was picturing ending up with four variables, two for initial and two for static, but this way is probably better - just needs better naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address first part of this comment and change the variables back form static
to initial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done the changes
server.go
Outdated
// StaticStreamWindowSize returns a ServerOption to set the initial stream | ||
// window size to the value provided and prevents dynamic flow control | ||
// from adjusting it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// StaticStreamWindowSize returns a ServerOption to set the initial stream | |
// window size to the value provided and prevents dynamic flow control | |
// from adjusting it. | |
// StaticStreamWindowSize returns a ServerOption to set the initial stream | |
// window size to the value provided and disables dynamic flow control. | |
// The lower bound for window size is 64K and any value smaller than that | |
// will be ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
server.go
Outdated
// StaticConnWindowSize returns a ServerOption to set the initial connection | ||
// window size to the value provided and prevents dynamic flow control | ||
// from adjusting it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// StaticConnWindowSize returns a ServerOption to set the initial connection | |
// window size to the value provided and prevents dynamic flow control | |
// from adjusting it. | |
// StaticConnWindowSize returns a ServerOption to set the initial connection | |
// window size to the value provided and disables dynamic flow control. | |
// The lower bound for window size is 64K and any value smaller than that | |
// will be ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
server.go
Outdated
staticWindowSize int32 | ||
staticConnWindowSize int32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
internal/transport/http2_client.go
Outdated
icwz := int32(initialWindowSize) | ||
if opts.InitialConnWindowSize >= defaultWindowSize { | ||
icwz = opts.InitialConnWindowSize | ||
dynamicWindow = false | ||
dynamicWindow = opts.UseDynamicWindowSizing | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is wrong now.
dynamicWindow
can be removed, and opts.Use...
can be used in its place. Same on the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I've updated the code accordingly
internal/transport/http2_client.go
Outdated
@@ -309,11 +309,11 @@ func NewHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts | |||
scheme = "https" | |||
} | |||
} | |||
dynamicWindow := true | |||
opts.UseDynamicWindowSizing = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't alter the setting here. It's already set from the user. Setting this undoes it.
Did you run into problems with tests? Those tests would need to set this option accordingly. Also the below suggestion might help some, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was facing issues in the tests. I've now removed the setting and updated the tests to set the option explicitly as needed.
internal/transport/transport.go
Outdated
MaxHeaderListSize *uint32 | ||
HeaderTableSize *uint32 | ||
BufferPool mem.BufferPool | ||
UseDynamicWindowSizing bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this name is the default behavior (disabled) is not our current default (enabled).
So let's rename these to StaticWindowSize
please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback!, I've renamed it to StaticWindowSize for clarity and to better reflect the actual default behavior. The code has been updated accordingly.
dialoptions.go
Outdated
@@ -213,6 +213,7 @@ func WithReadBufferSize(s int) DialOption { | |||
func WithInitialWindowSize(s int32) DialOption { | |||
return newFuncDialOption(func(o *dialOptions) { | |||
o.copts.InitialWindowSize = s | |||
o.copts.StaticWindowSize = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These (4) need to be true
or you will be changing behavior, which is not what we want yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification!, I've updated the code so that all four values are set to true
internal/transport/http2_client.go
Outdated
icwz := int32(initialWindowSize) | ||
if opts.InitialConnWindowSize >= defaultWindowSize { | ||
icwz = opts.InitialConnWindowSize | ||
dynamicWindow = false | ||
opts.StaticWindowSize = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't alter the setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
internal/transport/http2_client.go
Outdated
} | ||
if dynamicWindow { | ||
if opts.StaticWindowSize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if opts.StaticWindowSize { | |
if !opts.StaticWindowSize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Part of: #7923
RELEASE NOTES:
DialOptions
andServerOptions
(WithStaticStreamWindowSize
,WithStaticConnWindowSize
,StaticStreamWindowSize
,StaticConnWindowSize
) that force fixed window sizes for all HTTP/2 connections. By default, gRPC uses dynamic sizing of these windows based upon a BDP estimation algorithm. The existing options (WithInitialWindowSize
, etc) also disable BDP estimation, but this behavior will be changed in a following release.