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

OkHttp: Flushes headers out immediately for client streaming and bidi streaming #274

Merged
merged 1 commit into from
Apr 27, 2015

Conversation

madongfly
Copy link
Contributor

Flushes headers out immediately for OkHttp transport, so that the server can be aware of the stream before receiving real data (or half close).

Adds corresponding test to AbstractTransportTest.

@iamqizhao
Copy link

I am curious why this is the way to do. This actually doubles the number of
syscall on client writing path because otherwise header and data can be
fused into a single write syscall (unless the header has some
user-specified metadata). This has some performance impact given the proper
designed benchmarks.

On Tue, Apr 7, 2015 at 12:03 AM, Xudong Ma notifications@github.com wrote:

Flushes headers out immediately for OkHttp transport, so that the server
can be aware of the stream before receiving real data (or half close).

Adds corresponding test to AbstractTransportTest.

You can view, comment on, or merge this pull request online at:

#274
Commit Summary

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#274.

@madongfly
Copy link
Contributor Author

@iamqizhao, you are right, this flush should only be made for client streaming and bi-di streaming. I'll continue working on it.

@iamqizhao
Copy link

Can you elaborate why it is necessary for client streaming and bi-di
streaming? Thanks.

On Tue, Apr 7, 2015 at 12:24 AM, Xudong Ma notifications@github.com wrote:

@iamqizhao https://github.com/iamqizhao, you are right, this flush
should only be made for client streaming and bi-di streaming. I'll continue
working on it.


Reply to this email directly or view it on GitHub
#274 (comment).

@madongfly
Copy link
Contributor Author

@iamqizhao, my understanding is that there may be some use cases like I made in the test: the server side wants to decide (maybe after checking some metadata in the Header like you said) whether the client can start sending.

@ejona86 and @a11r can provide more info.

@iamqizhao
Copy link

On Tue, Apr 7, 2015 at 12:38 AM, Xudong Ma notifications@github.com wrote:

@iamqizhao https://github.com/iamqizhao, my understanding is that there
may be some use cases like I made in the test: the server side wants to
decide (maybe after checking some metadata in the Header like you said)
whether the client can start sending.

Yup, but this is a special treatment for header metadata. We should not
flush if that is not the case.

@ejona86 https://github.com/ejona86 and @a11r https://github.com/a11r
can provide more info.


Reply to this email directly or view it on GitHub
#274 (comment).

StreamingInputCallResponse response = responseObserver.firstValue().get();
// Server sent a special message to tell us start uploading.
assertEquals(-1, response.getAggregatedPayloadSize());
for (StreamingInputCallRequest request : requests) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there much of a point in actually sending any requests at this point? Even if one request is useful, why 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No point, just copied the code from the clientStreaming test.

I'll change it to just 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@ejona86
Copy link
Member

ejona86 commented Apr 7, 2015

Yup, but this is a special treatment for header metadata.

@iamqizhao, no. That is just the wanted semantics. I would be strongly oppose special casing the flush only if there is custom metadata. We should always do it or never do it. Given the zero-message semantics of streaming and the ability of long-lived requests, the most sensible thing seemed to be to flush. @a11r felt the same way, even before I shared my opinion.

@madongfly madongfly changed the title Fix for #257. OkHttp: Flushes headers out immediately. Apr 8, 2015
@madongfly madongfly changed the title OkHttp: Flushes headers out immediately. OkHttp: Flushes headers out immediately for client streaming and bidi streaming Apr 8, 2015
@madongfly
Copy link
Contributor Author

@ejona86 Could you take another look, thanks!

@madongfly
Copy link
Contributor Author

@ejona86 PTAL, thanks!

@iamqizhao
Copy link

On Tue, Apr 7, 2015 at 9:54 AM, Eric Anderson notifications@github.com
wrote:

Yup, but this is a special treatment for header metadata.

@iamqizhao https://github.com/iamqizhao, no. That is just the wanted
semantics. I would be strongly oppose special casing the flush only if
there is custom metadata. We should always do it or never do it. Given the
zero-message semantics of streaming and the ability of long-lived requests,
the most sensible thing seemed to be to flush. @a11r
https://github.com/a11r felt the same way, even before I shared my
opinion.

It is an important performance optimization and has non-trivial performance
impact especially for high-qps applications. I will keep it as an important
knob for performance tuning. I will talk to abhishek sometime next week.


Reply to this email directly or view it on GitHub
#274 (comment).

@madongfly
Copy link
Contributor Author

Ping, any update? @iamqizhao @ejona86

@ejona86
Copy link
Member

ejona86 commented Apr 21, 2015

@madongfly, I'm still unsettled about the integration test. Can we do this change without a new integration test? If you'd like, you can add a new TODO to our integration test doc (if you reference me (with @) then I'd be happy to merge the change).

A unit test in OkHttpClientTransportTest should be enough for now.

@madongfly
Copy link
Contributor Author

@ejona86 Why do you dislike a new integration test? Are you planing to make the integration test only implement the tests listed on the integration test doc?

Based on the only change made in this PR: flushing after synStream(), I think either we have a integration test to check the behavior in the wire level, or we just trust the newly added flush call and ignore the test. Having an unit test in OkHttpClientTransportTest to check whether the flush is called seems meaningless.

@ejona86
Copy link
Member

ejona86 commented Apr 22, 2015

@madongfly, the integration test proto is being kept in sync between all the languages. It is shared. I don't want to add something to it that I don't think should be implemented in all languages in the current form.

I'm suggesting that integration test is not a strong option at the moment. If we have an integration test, then yes, you could argue that a unit test is meaningless (although I could disagree with that). But a unit test doesn't seem meaningless if we don't have an integration test.

Given the size and nature of the change, I'm not super-concerned about a unit test (I'd merge without), but it would be nice.

@madongfly
Copy link
Contributor Author

@ejona86 Done, PTAL, thanks!

@ejona86
Copy link
Member

ejona86 commented Apr 27, 2015

@madongfly, LGTM.

#338 has advanced enough that we know how it relates to this PR. I was delaying to see how the Netty version looked.

…are of the stream before receiving real data (or half close).

Resolves grpc#257.
@madongfly madongfly merged commit 4b00476 into grpc:master Apr 27, 2015
@madongfly madongfly deleted the sendheader branch April 27, 2015 21:01
@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants