Skip to content

Consider reducing HeaderDescriptor size by using object field #62847

Description

@geoffkizer

Currently, the HeaderDescriptor struct has two fields:

        private readonly string _headerName;
        private readonly KnownHeader? _knownHeader;

A HeaderDescriptor is either:
(1) a known header, in which case KnownHeader is not null and _headerName is equal to _knownHeader.Name; or
(2) a custom header, in which case KnownHeader is null

We use HeaderDescriptor as the key for the HttpHeader header dictionary, which means we end up having a lot of instances of this structure.

We could optimize for memory here by combining these two fields into a single object field that contains either a string or a KnownHeader, and then do type casts. This would result in a small amount of additional CPU work to do the casts, but this may be worth the memory savings.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Net.HttpenhancementProduct code improvement that does NOT require public API changes/additionstenet-performancePerformance related issue

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions