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

Use of CoreCLR GC in conservative stack scanning mode #61919

Closed
joshpeterson opened this issue Nov 22, 2021 · 9 comments
Closed

Use of CoreCLR GC in conservative stack scanning mode #61919

joshpeterson opened this issue Nov 22, 2021 · 9 comments
Labels
area-GC-coreclr question Answer questions and provide assistance, not an issue with source code or documentation. untriaged New issue has not been triaged by the area owner

Comments

@joshpeterson
Copy link
Contributor

In the (currently internal) Unity prototypes using CoreCLR as an embedded JIT runtime, we have been using the CoreCLR GC in its conservative stack scanning mode. We understand this mode is not supported for production use. Is this something Microsoft would consider supporting?

It looks like existing Unity native code does enough access to managed objects that we will need to run in this mode to use the CoreCLR GC. We can work on limiting this kind of access in the Unity code, but that is a task that will take much longer than our planned CoreCLR migration. So we would like to use conservative stack scanning now.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Nov 22, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@joshpeterson
Copy link
Contributor Author

It looks like area-GC-coreclr would be a good label for this.

@joshpeterson
Copy link
Contributor Author

cc @jkotas @Maoni0

@jkotas
Copy link
Member

jkotas commented Nov 22, 2021

The conservative stack scanning mode has functionality and performance issues.

  • It is not unusual to see code out there that depends on the precise scanning and unreachable objects to get released in finite amount of time. The conservative stack scanning breaks it intermittently.
  • It adds about 20% GC overhead due to additional roots and pinning in GC intensive workloads on average. You can get easily get outliers when a bad pointer gets stuck on the stack.

Is this something Microsoft would consider supporting?

I see conservative stack scanning mode as community supported. We are fine with taking fixes for it, assuming these fixes would not conflict with the precise stack scanning mode.

We would not be able to make it officially Microsoft supported or recommended to use in CoreCLR runtime. Microsoft supported means that the feature has to be handle workloads like https://devblogs.microsoft.com/dotnet/azure-active-directorys-gateway-is-on-net-6-0/ with confidence. The conservative stack scanning is too brittle to do that.

@jkotas jkotas added area-GC-coreclr question Answer questions and provide assistance, not an issue with source code or documentation. labels Nov 22, 2021
@ghost
Copy link

ghost commented Nov 22, 2021

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

Issue Details

In the (currently internal) Unity prototypes using CoreCLR as an embedded JIT runtime, we have been using the CoreCLR GC in its conservative stack scanning mode. We understand this mode is not supported for production use. Is this something Microsoft would consider supporting?

It looks like existing Unity native code does enough access to managed objects that we will need to run in this mode to use the CoreCLR GC. We can work on limiting this kind of access in the Unity code, but that is a task that will take much longer than our planned CoreCLR migration. So we would like to use conservative stack scanning now.

Author: joshpeterson
Assignees: -
Labels:

area-GC-coreclr, untriaged

Milestone: -

@joshpeterson
Copy link
Contributor Author

I see conservative stack scanning mode as community supported. We are fine with taking fixes for it, assuming these fixes would not conflict with the precise stack scanning mode.

What level does community support have with respect to testing? We're fine to maintain this where necessary, but will existing CI run with this mode enabled? Or will we need to handle that?

@jkotas
Copy link
Member

jkotas commented Nov 22, 2021

We are fine with having cheap basic coverage in the CI runs for the community supported targets or features. For example, it would be fine to add a test under src\tests that runs with gcConservative mode and verifies that the conservative mode is not completely broken e.g. by creating a few threads, throwing some exceptions, triggering a couple of GCs. We can use this issue to track adding the test like that.

Adding the full CI coverage for the gcConservative mode would be too expensive for us. In the limit, it would almost double the CI matrix, and more than double the intermittent failures that we spend a lot of time dealing with already.

It would be up to you to ensure the quality bar you need for the gcConservative mode.

@EgorBo
Copy link
Member

EgorBo commented Dec 28, 2021

2 cents: our libs tests already aware of "conservative" mode so around a hundred of tests are disabled for it via IsPreciseGcSupported property, see https://github.com/dotnet/runtime/search?q=IsPreciseGcSupported

because of Mono obviously.

@joshpeterson
Copy link
Contributor Author

An update from the Unity side: We've decided not to pursue this option. Instead Unity plans to adjust our code so that it will work with the CoreCLR GC in its normal operation.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-GC-coreclr question Answer questions and provide assistance, not an issue with source code or documentation. untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

3 participants