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

Remove ConcurrentDictionary lookups from Unix socket event loop #109052

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MihaZupan
Copy link
Member

Running a bunch of different scenarios, this appears to be a slight improvement (<= 1%) on average, but that's below the run-to-run variance for these benchmarks.

@sebastienros is something like scenarios/platform.benchmarks.yml --scenario plaintext --profile aspnet-gold-lin reasonable for ASP.NET these days?

cc: @tmds @benaadams

@MihaZupan MihaZupan added this to the 10.0.0 milestone Oct 19, 2024
@MihaZupan MihaZupan requested review from antonfirsov and a team October 19, 2024 19:49
@MihaZupan MihaZupan self-assigned this Oct 19, 2024
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 Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

/// <para>Instead, we reuse handles for new sockets. The race condition may therefore trigger a notification for the wrong socket,
/// but that is okay as those operations can be retried.</para>
/// </summary>
private static readonly ConcurrentQueue<GCHandle> s_gcHandles = new();
Copy link
Member

@stephentoub stephentoub Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this pool really necessary?

#95098

Copy link
Member Author

@MihaZupan MihaZupan Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a typical pool (correctness more-so than perf). As the comment above describes, we're never freeing these handles since their lifetime is tricky.
This pool is here to avoid completely leaking a handle per socket, instead capping their number at whatever peak load the process reaches. That seems fine given that even with the dictionary, we wouldn't ever resize it back down.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dictionary has only a small overhead of memory per slot. What is the impact of never releasing a GCHandle?

Copy link
Member Author

@MihaZupan MihaZupan Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About 8 bytes * peak socket count.
I'm guessing the more meaningful impact would be on the GC throughput if you really have a ton of these laying around.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

2 participants