prometheus-net.DotNetRuntime icon indicating copy to clipboard operation
prometheus-net.DotNetRuntime copied to clipboard

Consider using new GetGCMemoryInfo API when targeting net5.0+

Open rwkarg opened this issue 4 years ago • 2 comments

This is extended information that may be able to pull GC info in a way that is less performance intensive.

Blog Post: https://devblogs.microsoft.com/dotnet/the-updated-getgcmemoryinfo-api-in-net-5-0-and-how-it-can-help-you/

rwkarg avatar Nov 27 '20 20:11 rwkarg

So I have looked at this API and it's something I might consider for v4 but at the moment I'm leaning away from it:

  • it isn't clear how this API can be used to get information on all GC collections (do you endlessly call this method in a loop?) as it just seems to return metrics on the last collection that occurred
  • the overhead of listening to Info level GC events is actually quite low

djluck avatar Nov 28 '20 03:11 djluck

That API isn't meant to be used for getting info on all GC collections - for that using EventListener as this library currently does is the current recommendation.

GCMemoryInfo API can help you though, if you're interested in sampling. This is the backing API for some of the runtime GC counters published by CoreCLR.

sywhang avatar Feb 18 '21 19:02 sywhang