Skip to content

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Feb 27, 2020

Sync changes from dotnet/aspnetcore#19393. Review now, but wait until that PR is merged before merging this.

Optimizing the enumerator eliminates allocations per HTTP request.

@JamesNK JamesNK requested a review from a team February 27, 2020 22:54

public bool BeginEncode(IEnumerable<KeyValuePair<string, string>> headers, Span<byte> buffer, out int length)
public bool BeginEncode(HeadersEnumerator enumerator, Span<byte> buffer, out int length)
Copy link
Member

Choose a reason for hiding this comment

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

I thought the point was that HttpClient didn't need these APIs and they could be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

HttpClient might not use this code but non-Kestrel code in our repo does, e.g. HttpSys tests, httpcat.

I changed my PR to use an #if. It minimizes the amount of overall change.

Copy link
Member

Choose a reason for hiding this comment

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

Minimizing changes is not critical at this point, I'd rather have a clean result. If only test code needs these old APIs then is there something straightforward we can do to restructure how they call this?

In the design for dynamic header compression we've already proposed changes that would require moving this enumerator outside of HPackEncoder. Maybe now is a good time to separate them.

Copy link
Member Author

Choose a reason for hiding this comment

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

If only test code needs these old APIs

Kestrel and tests use these APIs. My previous copied and pasted class that wrapped HPackEncoder still was the same API. I have just changed separation of our custom enumerator to use an #if.

Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

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

Approved with the understanding that you plan to rewrite/remove these APIs when working on static compression.

@JamesNK
Copy link
Member Author

JamesNK commented Mar 3, 2020

I don't have write permissions. Someone who does will need to merge it.

Copy link
Contributor

@scalablecory scalablecory left a comment

Choose a reason for hiding this comment

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

It looks fine, but I think it'd be worth looking at why the encoder needs to hold a copy of the enumerator -- from high-level view it seems like this API can go away, the field can go away, and the class made static (until we add dynamic table encoding, then it'll need some other state).

@scalablecory
Copy link
Contributor

/azp list

@scalablecory
Copy link
Contributor

/azp run runtime-libraries outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Tratcher
Copy link
Member

Tratcher commented Mar 3, 2020

It looks fine, but I think it'd be worth looking at why the encoder needs to hold a copy of the enumerator -- from high-level view it seems like this API can go away

Agreed. That's being investigated in the next PR. dotnet/aspnetcore#19521

@Tratcher Tratcher merged commit c2d20dd into dotnet:master Mar 3, 2020
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants