Skip to content

Conversation

@fiadliel
Copy link
Contributor

In order to support gRPC's flow control, the service has to handle
call.isReady and the onReady callback. When isReady is false,
the code should wait for onReady to be true. To avoid race conditions
where we may miss a wakeup, the isReady condition is checked twice;
once before, and once after assigning the wakeup Deferred value.

Fixes #38

In order to support gRPC's flow control, the service has to handle
`call.isReady` and the `onReady` callback. When `isReady` is false,
the code should wait for `onReady` to be true. To avoid race conditions
where we may miss a wakeup, the `isReady` condition is checked twice;
once before, and once after assigning the wakeup `Deferred` value.

Fixes #38
@fiadliel
Copy link
Contributor Author

@rossabaker @ahjohannessen
I haven't done any testing yet, but opinions welcome. Also, do we want this in 0.4.0, or leave for afterwards? (given this is an existing issue).

@fiadliel
Copy link
Contributor Author

Thinking about it, there are enough subtleties here that it might be best to release without this, and bake it for a while a later version.

@ahjohannessen
Copy link
Collaborator

This is a great addition, but perhaps, as you say, best to let it bake for a while and add tests.

@rossabaker
Copy link
Member

My big itch was to have a release on fs2-1.0. We've achieved that with the milestones, so I don't have strong opinions on whether this is makes it into 0.4.0 or a subsequent release.

@rossabaker
Copy link
Member

This has fallen a bit behind. Is this still something we want?

@ahjohannessen
Copy link
Collaborator

@rossabaker When @fiadliel says this

Thinking about it, there are enough subtleties here that it might be best to release without this

it makes me a bit nervous with respect to stability and correctness. Perhaps tests and some canaries in the wild are needed.

@ahjohannessen
Copy link
Collaborator

@fiadliel I think this is important to support. What is needed to move this forward and what are the subtleties?

Copy link

@flipp5b flipp5b left a comment

Choose a reason for hiding this comment

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

@fiadliel, first of all thank you for the great library and this PR!

I just want to throw in my two cents, maybe these comments would be useful.

def sendMessage(message: Response)(implicit F: Sync[F]): F[Unit] =
F.delay(call.sendMessage(message))

def sendMessageOrDelay(message: Response)(implicit F: Concurrent[F]): F[Unit] =
Copy link

Choose a reason for hiding this comment

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

Shouldn't this method be called inside Fs2ServerCallListener#handleStreamResponse instead of Fs2ServerCall#sendMessage? It looks like current implementation of server streaming doesn't take backpressure into account.

sendMessage(message), {
Deferred[F, Unit].flatMap { wakeup =>
wakeOnReady.set(wakeup.some) *>
isReady.ifM(sendMessage(message), wakeup.get *> sendMessage(message))
Copy link

Choose a reason for hiding this comment

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

Shouldn't we check isReady after wakeup.get completes to deal with missed wakeup?

@timbertson
Copy link
Contributor

I'd love to see some progress on this work, any help needed? It seems like the code isn't huge, is the main remaining thing perhaps some extra tests?

@ahjohannessen
Copy link
Collaborator

@timbertson The code in this PR is outdated. There is also the question if #503 changes the status around flow control if it gets merged.

@timbertson
Copy link
Contributor

Thanks @ahjohannessen . Based on #503 (comment) it sounds like backpressure will be unchanged in that branch.

I've opened #544 as an updated version of this PR, but targeted at v0.x.

@ahjohannessen
Copy link
Collaborator

Fixed by @timbertson in #552 #553

@ahjohannessen ahjohannessen deleted the flow_control branch November 4, 2022 12:49
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.

No throttling of message sending

6 participants