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

  1. added this to the Future milestone on Dec 15, 2021
  2. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Dec 15, 2021
  3. karelz commented on Dec 16, 2021

    @karelz
    Member

    Triage:

    • We should measure CPU impact it to see if it is worth it -- combining both fields into single one.
      • In YARP we expect 2% memory savings. CPU impact should be negligible, but we should check.
  4. added
    enhancementProduct code improvement that does NOT require public API changes/additions
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Dec 16, 2021
  5. self-assigned this
    on Dec 18, 2021
  6. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Dec 18, 2021
  7. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jan 6, 2022
  8. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jan 21, 2022
  9. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Feb 1, 2022
  10. ghost locked as resolved and limited conversation to collaborators on Mar 3, 2022
  11. modified the milestones: Future, 7.0.0 on Apr 8, 2022
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