CronetBidirectionalStream #2164
Conversation
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
StefanoDuo
left a comment
There was a problem hiding this comment.
I've started going through the code and I've a bunch of questions. @carloseltuerto feel free to either reply here or ping me tomorrow.
library/java/org/chromium/net/impl/CronetBidirectionalStream.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalStream.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalStream.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
StefanoDuo
left a comment
There was a problem hiding this comment.
I haven't looked at CancelProofEnvoyStream, CronetUrlRequest* and the tests since they are orthogonal to the bidi stream implementation.
library/java/org/chromium/net/impl/CronetBidirectionalState.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalState.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalState.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalStream.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalStream.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalStream.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
RyanTheOptimist
left a comment
There was a problem hiding this comment.
High-level comment. There are thousands of lines of code added in the PR. Are there any ways we could consider breaking it up into smaller pieces?
In any case, this is awesome!
library/java/org/chromium/net/impl/CronetBidirectionalState.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalState.java
Outdated
Show resolved
Hide resolved
This PR is a deal with the devil: you have code avoiding as much as possible "task switching"/"synchronisation", however, an implementation with blocking semantics (java "synchronized") would probably be easier (still tricky). And there is a class that could be in an isolated PR: CronetBidirectionalState (and the test: CronetBidirectionalStateTest). However, my appreciation of the situation is this would be a pointless exercise. By just looking at that class and its test, it is impossible to infer what how it is used: the caller is needed too to get a sense of what is going on. And there is one class that does not need much scrutiny: |
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
RyanTheOptimist
left a comment
There was a problem hiding this comment.
Thanks for the thoughtful response! It looks like CancelProofEnvoyStream could be extracted from the PR as a stand-alone change (even if it wouldn't be used yet). I would definitely consider doing that.
library/java/org/chromium/net/impl/CronetBidirectionalState.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetBidirectionalState.java
Outdated
Show resolved
Hide resolved
library/java/org/chromium/net/impl/CronetUrlRequestContext.java
Outdated
Show resolved
Hide resolved
|
Ryan wrote: I created an "issue" for this: #2247 |
|
Ryan wrote: One of the great virtue of Compare-And-Swap is that it can't deadlock. There is always one Thread that will succeed - the others may/will loop, and so forth. IBM calls that loop around the CS mnemonic a "spin lock" - they were the first to come up with a dedicated mnemonic for that. (I was a student in 1987 - I wrote a small Assembler for IMB360 as a project) |
Ugh, github somehow moved this discussion from the comment in the code to the main conversation page. Man, I hate github. Can you explain what would happen if |
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
- Add more documentation - Rearrange and rename State and Action to make them more consistant Signed-off-by: Charles Le Borgne <cleborgne@google.com>
RyanTheOptimist
left a comment
There was a problem hiding this comment.
Thanks for doing all this, Charles. I'm slightly apprehensive about the maintainability / complexity of the state machine, but we and always address that later if it turns out to be problematic. LGTM
@alyssawilk care to take a look?
Signed-off-by: Charles Le Borgne <cleborgne@google.com>
|
@RyanTheOptimist I strongly suspect my pass isn't going to add much value to the review you've already done. I'd be inclined to merge as-is and as you say we can revisit complexity later if we need to. SGTY or you actively prefer I do a pass? |
Works for me! I'll go ahead and merge now. |
* main: build: remove dist/ (#2184) Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221) Add comments to CronetBidirectionalStream (#2266) CronetBidirectionalStream (#2164) ci: update build image (#2261) Bump Lyft Support Rotation (#2260) Signed-off-by: JP Simard <jp@jpsim.com>
* main: build: remove dist/ (#2184) Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221) Add comments to CronetBidirectionalStream (#2266) CronetBidirectionalStream (#2164) ci: update build image (#2261) Bump Lyft Support Rotation (#2260) Signed-off-by: JP Simard <jp@jpsim.com>
* main: Add assert when failing to get_env (#2253) Update Kotlin standard libraries to 1.6.21 (#2256) iOS: Change release artifacts to use xcframeworks (#2217) build: remove dist/ (#2184) Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221) Add comments to CronetBidirectionalStream (#2266) CronetBidirectionalStream (#2164) Signed-off-by: JP Simard <jp@jpsim.com>
This is the initial PR to address #1642. The BidirectionalStreamTest has been ported "as is". Caveats:
@Ignoretests:The implementation does not use
synchronized. The logic is 100% Compare-And-Swap based.This is the test that was executed to hopefully catch all race conditions:
Description: Initial CronetBidirectionalStream implementation
Risk Level: none: only touches Cronvoy
Testing: CI, and multi concurrent runs (many time 500 runs)
Docs Changes: N/A
Release Notes: N/A