Skip to content

Consider making array allocation size in HPackDecoder configurable. #60313

@AlgorithmsAreCool

Description

@AlgorithmsAreCool

Description

I've been evaluating the use of gRPC streaming in aspnet at scale for an IoT scenario. I was a little surprised to find out that a single connection requires ~50KB of memory. Since I am planning to scale to >100,000 connections, I would look to maximize the density of the connections per machine.

Looking deeper at the memory usage, a large chunk (12kb) is taken up by 3 4KB preallocated arrays in the HPackDecoder. I wonder if this size is overly aggressive in the general case w.r.t. memory consumption per connection.

Does anyone know why this size was chosen?

.NET SDK:
 Version:           9.0.200-preview.0.25057.12
 Commit:            cf6faae8d1
 Workload version:  9.0.200-manifests.693890c1
 MSBuild version:   17.13.0-preview-24569-04+8f6b8ad0a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.200-preview.0.25057.12\

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

Regression?

No, this allocation is years old.

Data

Image

Analysis

This is the location of the array allocations. If perhaps

https://github.com/dotnet/runtime/blob/0f0f8ce751134cccf11e47c90f781597039146ef/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HPackDecoder.cs#L116-118

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsuntriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions