SiliconStudio / xenko

Old repo for Xenko Game Engine. Please use https://github.com/xenko3d/xenko instead.
http://xenko.com
1.54k stars 345 forks source link

Garbage collection pauses #529

Open MihaMarkic opened 7 years ago

MihaMarkic commented 7 years ago

Hi, I wonder whether xenko is affected by .net GC runs. I'd guess so.

manu-st commented 7 years ago

Like any other C# programs, Xenko relies on the .NET GC for its memory management and we do as much as possible to minimize the impact of the GC on Xenko programs.

MihaMarkic commented 7 years ago

Do you have any benchmarks or practical data? Just curious whether I can consider a native .net for graphics stack.

manu-st commented 7 years ago

Benchmarks depends if you are CPU or GPU bound. For GPU bound programs, there will be little difference between native and C# assuming similar graphic engine backend. For CPU bound programs, there might be some (probably small) differences but the overall benefits of using C# over a native language is what makes a difference in the long run.

Going back to the Xenko engine itself, it offers some nice features that aim at getting more out of the GPU and thus more fps for your games. So maybe it should not be C# vs native, but more comparing the features of the engines you are considering and hopefully Xenko is the one you want to use.

MihaMarkic commented 7 years ago

I'm sure it's well featured. I'm just concerned about GC pause, that's it. I wonder how long are the pauses in well behaved application (carefully avoiding allocations, etc.).

manu-st commented 7 years ago

I do not have off hand benchmarks for this but I found this article that provides some good clues at what you can expect:

http://mattwarren.org/2017/01/13/Analysing-Pause-times-in-the-.NET-GC/

EnoughTea commented 7 years ago

Launch one of the more complex Xenko demos like TopDownRPG and take a look with PerfView. You will see that render resource-related types are allocated and freed periodically. So you can expect a GC kicking in every few seconds.

As for the time impact of garbage collections, you can just launch ProcessExplorer and take a look at ".NET performance" tab in process properties, namely "% Time in GC". In TopDownRPG demo, for example, it is roughly ≈0.4 % of time spent GC-ing for me. So measure and decide for your case, if it is fast enough or not.