dotnet / runtime

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

Add tracing around assembly unload #45264

Open vitek-karas opened 3 years ago

vitek-karas commented 3 years ago

The unloading support in .NET Core is reliant on GC and very "asynchronous". The app typically only asks for unload by calling ALC.Unload but then has to wait across multiple GC runs until the unload actually happens. There's also not a simple way to get notified that unload actually happened. (One can poll using a weak ref though).

To make this process easier to diagnose it would be helpful to have tracing events which can be used to detect the start and end of an unload operation. Maybe we can add some more detail if there are intermediate steps in the process which would make sense as well.

See https://github.com/dotnet/runtime/issues/44679 for an example of a discussion on this topic.

ghost commented 3 years ago

Tagging subscribers to this area: @vitek-karas, @agocke, @coffeeflux See info in area-owners.md if you want to be subscribed.

Issue Details
The unloading support in .NET Core is reliant on GC and very "asynchronous". The app typically only asks for unload by calling `ALC.Unload` but then has to wait across multiple GC runs until the unload actually happens. There's also not a simple way to get notified that unload actually happened. (One can poll using a weak ref though). To make this process easier to diagnose it would be helpful to have tracing events which can be used to detect the start and end of an unload operation. Maybe we can add some more detail if there are intermediate steps in the process which would make sense as well. See https://github.com/dotnet/runtime/issues/44679 for an example of a discussion on this topic.
Author: vitek-karas
Assignees: -
Labels: `area-AssemblyLoader-coreclr`
Milestone: -
vitek-karas commented 3 years ago

/cc @CoffeeFlux - for mono side of things

aloksharma1 commented 2 weeks ago

are there any updates on this issue, in one of my projects we are relying on assembly unload to reload fresh assemblies dynamically built by roslyn on runtime. and sometimes it randomly stops refreshing, so in order to find the cause i did some digging and came here btw i'm using dotnet 8.