Skip to content

Conversation

@davidfowl
Copy link
Member

  • When data comes in from the transport or sent to the transport, we use the default pipe buffer size on the client (which is 65K). This change makes it possible to configure both the transport buffer and the application buffer so that it can be configured based on users scenarios.
  • Raise the default limit from 65K to 1MB on the client side and raise it from 32K (old pipe limit) to 65K on the server side.

Fixes #17797

PS: I haven't figured out how to test this as yet.

- When data comes in from the transport or sent to the transport, we use the default pipe buffer size on the client (which is 65K). This change makes it possible to configure both the transport buffer and the application buffer so that it can be configured based on users scenarios.
- Raise the default limit fro 65K to 1MB on the client side and raise it from 32K (old pipe limit) to 65K on the server side.
@ghost ghost added the area-signalr Includes: SignalR clients and servers label Aug 6, 2021
Copy link
Member

@BrennanConroy BrennanConroy left a comment

Choose a reason for hiding this comment

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

I hate to say it, but I'm not too concerned about tests for the client for this specific change. We do have tests that check backpressure for the server side that you could copy if you wanted.

I'm more concerned that no tests failed with the server-side buffer size change.

@davidfowl
Copy link
Member Author

I'm more concerned that no tests failed with the server-side buffer size change.

You're concerned we don't have a test that verifies the defaults?

@BrennanConroy
Copy link
Member

You're concerned we don't have a test that verifies the defaults?

More like, we should have some tests that send a message that's bigger than the limit to make sure it applies backpressure. But maybe we lower the limit in the test so we only send a couple bytes. But a test to check the default would be nice.

@davidfowl
Copy link
Member Author

More like, we should have some tests that send a message that's bigger than the limit to make sure it applies backpressure. But maybe we lower the limit in the test so we only send a couple bytes. But a test to check the default would be nice.

We do that already.

@BrennanConroy
Copy link
Member

Right, I'm assuming we do lower the limit in the test which is why the change didn't affect anything.

But maybe we lower the limit in the test so we only send a couple bytes.

@davidfowl
Copy link
Member Author

Right, I'm assuming we do lower the limit in the test which is why the change didn't affect anything.

Are you worried about the defaults or the feature?

@BrennanConroy
Copy link
Member

Defaults, pretty sure the feature is well tested

@davidfowl
Copy link
Member Author

Defaults, pretty sure the feature is well tested

I think if the feature works, it doesn't matter that we write a similar pause resume tests with the defaults. I don't mind writing a test that asserts what the defaults are though.

Thoughts?

// We initialize these lazily based on the state of the options specified here.
// Though these are mutable it's extremely rare that they would be mutated past the
// call to initialize the routerware.
internal PipeOptions TransportPipeOptions => _transportPipeOptions ??= new PipeOptions(pauseWriterThreshold: TransportMaxBufferSize, resumeWriterThreshold: TransportMaxBufferSize / 2, readerScheduler: PipeScheduler.ThreadPool, useSynchronizationContext: false);
Copy link
Member

Choose a reason for hiding this comment

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

Should we disallow -1 for these sizes? I don't think this is unique to SignalR, but after discussing it in API review, I realize this would lead to weird behavior where you'd get System.IO.Pipeline's default pauseWriterThreshold (64k), but not the default resumeWriterThreshold (0 instead of 32k) meaning all the data would need to be consumed before backpressure is relieved.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I thought -1 was unlimited, but it's defaults. It might make sense for the API to not allow -1 then.

@davidfowl davidfowl enabled auto-merge (squash) August 10, 2021 05:09
@davidfowl davidfowl merged commit 3535cfb into main Aug 10, 2021
@davidfowl davidfowl deleted the davidfowl/client-buffer-size-options branch August 10, 2021 07:07
@ghost ghost added this to the 6.0-rc1 milestone Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-signalr Includes: SignalR clients and servers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SignalR] Allow controlling maximum buffer size on client

4 participants