Skip to content

Accurately count only newly examined bytes #12639

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

Merged
merged 1 commit into from
Jul 29, 2019
Merged

Conversation

halter73
Copy link
Member

@halter73 halter73 commented Jul 27, 2019

  • Ensure Kestrel count all bytes read using TryRead
  • Ensure Kestrel doesn't double count examined but
    not consumed bytes

See #11942 (comment) for context

@halter73 halter73 added this to the 3.0.0-preview8 milestone Jul 27, 2019
@halter73 halter73 requested a review from Tratcher as a code owner July 27, 2019 00:41
@halter73 halter73 added the bug This issue describes a behavior which is not expected - a bug. label Jul 27, 2019
@halter73
Copy link
Member Author

TODO: Write regression tests. I just wanted everyone to see the proposed preview8 changes ASAP.

- Ensure Kestrel count all bytes read using TryRead
- Ensure Kestrel doesn't double count examined but
  not consumed bytes
@halter73 halter73 force-pushed the halter73/count-bytes branch from fe87720 to f53ebed Compare July 27, 2019 01:36
@halter73
Copy link
Member Author

@anurse @davidfowl I think we should take this for preview8.

@davidfowl
Copy link
Member

Any potential performance regression here?

@halter73
Copy link
Member Author

Doubt it totalLength = readResult.Buffer.Length; would be the only line that has much of a chance of impacting perf, but that only runs if you don't examine to the end of the buffer which should be exceedingly rare when reading the request body. The super sensitive benchmarks don't have a request body to begin with.

@analogrelay
Copy link
Contributor

I think we should take this for preview8.

Agreed, but just from a bureaucracy perspective, if it doesn't happen I feel confident taking this in preview 9. It seems edge-casey enough that I don't know if I'd block preview8 for this fix, but read-rate accounting is critical to the product so getting it in for preview9 seems fair.

Anyway, that's all moot if we can land it by Monday. Just setting the context and contingency plans.

@jkotalik
Copy link
Contributor

We will do cleanup for preview9. Functionally looks sound to me.

@halter73 halter73 merged commit 75f4159 into master Jul 29, 2019
@halter73 halter73 deleted the halter73/count-bytes branch July 29, 2019 17:14
{
_context.TimeoutControl.BytesRead(bytesRead - _alreadyTimedBytes);
_alreadyTimedBytes = 0;
var numFirstSeenBytes = bytesInReadResult - _alreadyTimedBytes;
Copy link
Member

Choose a reason for hiding this comment

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

@halter73 Should this then update _alreadyTimedBytes?

var numFirstSeenBytes = bytesInReadResult - _alreadyTimedBytes;

if (numFirstSeenBytes > 0)
{
    _context.TimeoutControl.BytesRead(numFirstSeenBytes);
    _alreadyTimedBytes = bytesInReadResult ;
}

Copy link
Member

Choose a reason for hiding this comment

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

Ah, nvm I think its ok

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. We count all the bytes in the ReadResult towards rate calculations, examined or not. Then in Advance, if we don't consume everything, we count all the unconsumed and unexamined bytes towards _alreadyTimedBytes, since both the unconsumed and unexamined bytes will be present in the next read result. What got you looking at this?

Copy link
Member

Choose a reason for hiding this comment

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

Was getting test failures with #11942 (comment) when I removed all the changes that weren't directly related to the streams; as assumed this superseded them.

Issue wasn't with counting though; needed TryStart/TryStop in Http2MessageBody

@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions bug This issue describes a behavior which is not expected - a bug. feature-kestrel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants