-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add flow control observability #7810
Conversation
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.
I think this is a handy instrumentation while we adjust these things, but I’m not sure about the long-term value of this?
okhttp/src/jvmMain/kotlin/okhttp3/internal/http2/Http2Connection.kt
Outdated
Show resolved
Hide resolved
} | ||
connection.flowControlListener.receivingStreamWindowChanged(id, readBytes, readBuffer.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.
Anything where we call a user-owned listener while holding a lock is bad news. Something to keep in mind if ever we wanted to make a public API.
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.
Yep. I am becoming more convinced for libraries like exoplayer we should make the flow control visible in some form. But happy to agree to remove this before 5.0 unless we find that nice API.
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.
I think this can move, out of synchronized, but inside the loop.
val streamId: Int | ||
) { | ||
/** The total number of bytes consumed. */ | ||
private val _total: AtomicLong = AtomicLong(0) |
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.
Why atomics?
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.
I don't think I'm clear on all the locking that goes on in all cases. I originally had a data class that was updated. Might switch back to that and define locking rules around writes.
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.
Removed, no need.
Add an internal API for receiving HTTP/2 flow control information, definitely not complete.
This shows
Connection - unacked on connection - this is not true in the first, as connection doesn't bump until consumed via a stream
3 - The unacked on stream 3 (the stalled request)
3-buffer - The data sitting inside the Buffer to be read
5 & 5-buffer - same as 3.
As an example used before and after this fix https://github.com/square/okhttp/pull/7801/files