-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add GC committed bytes counter #50604
Conversation
@@ -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" }; |
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 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...
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 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.
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.
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.
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.
sounds good, thanks @stephentoub and @sywhang.
This adds GC committed bytes counter to
System.Runtime
.