dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.37k stars 4.75k forks source link

[Profiler] Ability to call `DiagUpdateGenerationBounds()` from profiler API. #108276

Open ww898 opened 1 month ago

ww898 commented 1 month ago

Hi, my suggestion is based on the desire to get heap information updates not only at the beginning and end of GC, but also at any other time on request outside of GC. If the application does not perform GC for a long time after attaching the profiler, then we cannot make any assumptions about the amount of memory used. Calling ForceGC of course updates the heap information, but performs a full GC in addition, which breaks the picture of memory use.

https://github.com/dotnet/runtime/blob/79a71fc750652191eba18e19b3f98492e882cb5f/src/coreclr/vm/gcenv.ee.cpp#L809-L855

dotnet-policy-service[bot] commented 1 month ago

Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.

cshung commented 1 month ago

That would require non-trivial synchronization since the generation bounds are constantly being updated by allocation. At the very least, this requires some careful design.

ww898 commented 1 month ago

@cshung What do you think about creating the method like ICorProfilerInfo::ForceGC, but without gathering garbage in fact?