Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider making array allocation size in HPackDecoder configurable. #60313

Open
AlgorithmsAreCool opened this issue Feb 11, 2025 · 3 comments
Open
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions untriaged

Comments

@AlgorithmsAreCool
Copy link

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Feb 11, 2025
@huoyaoyuan huoyaoyuan removed the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Feb 11, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@MihaZupan
Copy link
Member

Moving to aspnetcore since the question was about the server side.
The situation is similar with outgoing connections (HttpClient) since this source is shared.

@MihaZupan MihaZupan transferred this issue from dotnet/runtime Feb 11, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Feb 11, 2025
@AlgorithmsAreCool
Copy link
Author

@MihaZupan My mistake, I think i was confused about how the sources are arranged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions untriaged
Projects
None yet
Development

No branches or pull requests

3 participants