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

Add GC committed bytes counter #50604

Merged
merged 3 commits into from
Apr 3, 2021

Conversation

sywhang
Copy link
Contributor

@sywhang sywhang commented Apr 1, 2021

This adds GC committed bytes counter to System.Runtime.

@@ -76,6 +77,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
var gcInfo = GC.GetGCMemoryInfo();
return gcInfo.HeapSizeBytes != 0 ? gcInfo.FragmentedBytes * 100d / gcInfo.HeapSizeBytes : 0;
}) { DisplayName = "GC Fragmentation", DisplayUnits = "%" };
_committedCounter ??= new PollingCounter("gc-committed", this, () => GC.GetGCMemoryInfo().TotalCommittedBytes) { DisplayName = "GC Committed Bytes", DisplayUnits = "B" };
Copy link
Member

Choose a reason for hiding this comment

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

it seems like we could easily avoid calling GC.GetGCMemoryInfo again if we already had to call it to get the info for the counter right above...

Copy link
Member

Choose a reason for hiding this comment

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

It's inside the lambda. Might be nice if there were some kind of facility for enabling all counters associated with the same event source to be handed the results of some shared computation, e.g. so that prior to invoking both gc-fragmentation and gc-committed, it could do a single GetGCMemoryInfo call that both would then be handed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this gets passed as a lambda and is executed by the CounterGroup. It would be nice to add what @stephentoub suggested so that counters within the same provider can share some state. I'll look into adding that in the future.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good, thanks @stephentoub and @sywhang.

@sywhang sywhang merged commit e52322d into dotnet:main Apr 3, 2021
@sywhang sywhang deleted the dev/suwhang/add-committed-size-counter branch April 3, 2021 05:48
@ghost ghost locked as resolved and limited conversation to collaborators May 3, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants