Skip to content

Improve Http.sys allocation profile and performance #22022

@davidfowl

Description

@davidfowl

AB#1240693

This isn't urgent in anyway but I wanted to keep track of the low hanging performance fruit in HttpSys server:

Http.sys optimizations

General

Accept loop

  • Use a single preallocated native overlapped per server (dispose after the accept loop is over)
  • This means getting rid of SafeNativeOverlapped (or making it a struct)
  • Make the NativeRequestContext a struct, it's basically a wrapper around a byte with helpers to extra data from a blob of memory.
    • Another option would be to merge it into the feature collection implementation (similar to IIS)
  • Allocate a single feature collection object that implements the request and response contract. Today we have 2 objects maybe out of legacy?

Bodies

  • Synchronous read can be implemented by pinning the user buffer (or we can throw like we do in Kestrel)
  • Implement span overloads (these are missing)
  • Remove Begin/End implementations, and use Task.ToApm helpers to implement Begin/End over
    • The Task/ValueTask based overloads (the Memory and Span overloads should be the only implementation)
    • Remove IAsyncResult implementations
  • Implement pattern from IIS implementation IValueTaskSource based implementations of IO
    • Single object re-used for IO (each request body), no overlapping operations allowed.
    • Reuse pre-allocated overlapped during reads and writes
  • Potentially use memory pool for output
  • This removes the need to pin user buffers and avoid fragmentation
  • May result in more copies (user buffer-> pinned buffer)

Client cert loader

  • TBD

Metadata

Metadata

Assignees

Labels

Perfaffected-fewThis issue impacts only small number of customersarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsenhancementThis issue represents an ask for new feature or an enhancement to an existing onepartner-impactseverity-majorThis label is used by an internal tool

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions