-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[API Proposal]: Exposing the total paused duration in GC. #66036
Comments
Tagging subscribers to this area: @dotnet/gc Issue DetailsBackground and motivationToday we have already exposed the total paused time as a percentage of the process time on the GetGCMemoryInfo API. In particular, through the This is useful, but what if I only want to numerator (i.e. the total amount of time paused in GC since the beginning of the process?). There is no way to get that value for now. API ProposalI am proposing to add an API on System.GC as follow: TimeSpan System.GC.GetTotalPauseDuration() This will return the total paused duration in the GC API Usage...
TimeSpan start = System.GC.GetTotalPauseDuration();
// ... Perform some work ...
TimeSpan end= System.GC.GetTotalPauseDuration();
Console.WriteLine(end - start + " was spent pausing in GC");
... Alternative DesignsWe have considered the alternative to add a field on the RisksNo response
|
@timmydo Hopefully, this can help with your performance analysis needs. |
Thanks! + @sudeepagarwal |
this looks good to me. can't wait to try it out. |
How is |
(*) Plurals - because for background GC, we pause for a few disjoint brief periods. |
So in other words, |
no, GetTotalPauseDuration() is always >= Sum(GCMemoryInfo.PauseDurations) GCMemoryInfo.PauseDurations are durations for when the GC is NOT running concurrently, in other words, these are the durations that GC did work while the managed threads are paused. they are never for when GC is doing work concurrently. whether there's one or multiple durations per GC is not really relevant here (yes, BGCs will report 2 durations while blocking GCs will report one per GC but that's an implementation detail). the reason why GetTotalPauseDuration() is always >= Sum(GCMemoryInfo.PauseDurations) is because GetGCMemoryInfo is a sampling API. so assuming you called it early enough and frequent enough to catch every single GC that happened, it means what you get from GetTotalPauseDuration will be exactly the same as the sum of what you get from every GC's PauseDurations. but if you don't sample frequent enough to get every single GC, what you get from GetTotalPauseDuration will be > Sum(GCMemoryInfo.PauseDurations). and yes, the reason why we wanted to provide the accumulated pause duration in its own API is to make it cheaper. this does not mean we will want to expose the accumulated version of all the data you get right now in GCMemoryInfo - most data simply does not make sense to be presented in an accumulated form. there are a couple of things that may make some sense to expose as accumulated, but no strong justification. |
namespace System;
public partial class GC
{
public static TimeSpan GetTotalPauseDuration();
} |
Background and motivation
Today we have already exposed the total paused time as a percentage of the process time on the GetGCMemoryInfo API.
In particular, through the
PauseTimePercentage
field on the GCMemoryInfo struct.This is useful, but what if I only want to numerator (i.e. the total amount of time paused in GC since the beginning of the process?). There is no way to get that value for now.
API Proposal
I am proposing to add an API on System.GC as follow:
This will return the total paused duration in the GC
API Usage
Alternative Designs
We have considered the alternative to add a field on the
GetGCMemoryInfo
API, this will also work, but if the only thing we wanted is just the total pause time, that API will carry a larger overhead than necessary.Risks
No response
The text was updated successfully, but these errors were encountered: