Skip to content

Performance stuttering occurs in .NET Core 2.2 + 3.0, some background thread exiting by the runtime and any GC aggravates the problem #13196

@WChrisK

Description

@WChrisK

I'm using C# for a rendering project. On .NET Core 3.0, every 10-15 seconds I'd start getting this small stutter while moving the camera around. It is a big enough of a negative that it significantly destroys the user experience of the application. However when I change to .NET Framework 4.8 or .NET Core 2.1 the performance issues (this small microstutter that that lasts for maybe 50-150ms) completely disappears.

Long story short after a lot of digging, I found out the following:

  • Any GC at all causes this 'microstutter', even gen0, and even for very small amounts of garbage

  • Lots of GC at gen0/gen1 is perfectly fine on Framework 4.8/Core 2.1

  • In Core 2.2 there's a random pause when some thread exits and it prints to the output console in VS2019. This occurs less in Core 2.2 since there's only one one thread that exits, but in Core 3.0 this happens a lot more frequently (every 10-15 seconds or so) and causes a lot more problems

There is some 'background thread' that appears to be exiting which is generated beyond my control (I assume this is the runtime according to the debugging it in the threads window). Whatever is generating this thread, I notice in the VS2019 console when it says "... thread has exited" I get a stutter. I am not doing any threading, the application is purely single threaded (not using TPL or PLINQ if that helps, no async or await either). Regardless, even in a simple 'hello world' console app I still notice the message appearing in the console.

I'm not sure why the presence of any kind of GC invocation causes pauses, or what this background thread that keeps getting spawned is (especially since it happens in a program that just prints hello world and then goes into a while(true) { } to prevent exiting). After some discussion online, other people seem to think it might be tiered compilation threads since it starts out causing microstutters every 10-15 seconds and then the gap gets wider and wider as time goes on, but I'm not sure what I could do to definitively prove or disprove this.

So what do I do? I could git bisect this repo until I find out the commits that make it worse. Is there anything else I could do to isolate what is causing it? Or am I writing an issue on the wrong repo (if so, where do I go)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions