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

Add flow control observability #7810

Merged
merged 4 commits into from
May 10, 2023
Merged

Add flow control observability #7810

merged 4 commits into from
May 10, 2023

Conversation

yschimke
Copy link
Collaborator

@yschimke yschimke commented May 8, 2023

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.

image

As an example used before and after this fix https://github.com/square/okhttp/pull/7801/files

image

@yschimke yschimke requested a review from swankjesse May 8, 2023 17:27
@yschimke
Copy link
Collaborator Author

yschimke commented May 8, 2023

Copy link
Member

@swankjesse swankjesse left a 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?

}
connection.flowControlListener.receivingStreamWindowChanged(id, readBytes, readBuffer.size)
Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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)
Copy link
Member

Choose a reason for hiding this comment

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

Why atomics?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed, no need.

@yschimke yschimke merged commit e882b4c into square:master May 10, 2023
20 checks passed
@yschimke yschimke deleted the flow_obs branch October 15, 2023 11:54
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.

None yet

2 participants