-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
base: main
Are you sure you want to change the base?
Conversation
Tagging subscribers to this area: @dotnet/ncl |
/azp run runtime-libraries-coreclr outerloop |
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, though I'd be surprised if it mattered at these numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When working on overall perf gains we should use the gold machines now, correct. I would suggest to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the offline chat about it!
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