5 ms·
If someone could do this for Unity, it would change my life.
by psyc 10y ago
If someone could do this for Unity, it would change my life.
- pcwalton 10y ago.NET already has concurrent garbage collection: https://msdn.microsoft.com/library/ee787088(v=vs.110).aspx#background_garbage_collection https://msdn.microsoft.com/library/ee787088(v=vs.110).aspx#b... See the "SustainedLowLatency" mode for something very similar to what Go does (although .NET's GC, unlike Go's GC, is generational, which is a significant difference).
- squeaky-clean 10y agoUnfortunately, Unity still uses .NET 2, and their next planned upgraded (to 4.6) is still listed as an undetermined eta. That's good to know for the future though.
- ijk 10y agoThey're beta-testing .NET 4.6 in Unity 5.5: https://forum.unity3d.com/threads/upgraded-mono-net-in-editor-on-5-5-0b9.438359/ https://forum.unity3d.com/threads/upgraded-mono-net-in-edito...
- kbenson 10y agoDoes unity actually use the .NET runtime, or mono? I was under the impression it used mono. Does that apply for mono?
- johncolanduoni 10y agoDepends on the platform you are targeting. Mono's GC (last I heard, they may have integrated .NET Core's by now) is relatively primitive. It was mostly developed just to have something better than Boehm. Their experience was actually pretty instructive; with their first release of the new GC (a proficient but basic generational collector) they still weren't beating Boehm all the time, and usually weren't beating it by much. Given its constraints, Boehm's GC is impressively optimized when you run it in semi-precise mode.
- pcwalton 10y agoWere they bump allocating in the nursery? That's where you tend to see the biggest gains from generational GC.
- johncolanduoni 10y agoYes, they even used TLABs. I believe the issue was that Xamarin was more interested in mobile performance at the time when SGEN was seeing heavy development and preparing for release, so they optimized for memory usage instead of throughput. The generational part was probably more of a hindrance than a benefit at that point in the process.
- marktangotango 10y agoVery interesting, I'm interested in how you came to this understanding. How did acquire information about this? Did they blog about it, or do you happen to follow their mailing lists, or ... ?
- johncolanduoni 10y agoI read a blog post from someone at Xamarin with some test cases graphed, a bit before Xamarin started suggesting SGEN as the default. I'll see if I can find the one I'm thinking of.
- matthewwarren 10y ago.NET also has the TryStartNoGCRegion API, which allows you too prevent all GC collections (for a certain while). See http://mattwarren.org/2016/08/16/Preventing-dotNET-Garbage-Collections-with-the-TryStartNoGCRegion-API/ http://mattwarren.org/2016/08/16/Preventing-dotNET-Garbage-C... for the full details
- weberc2 10y agoYou can do this in Go as well: https://golang.org/pkg/runtime/debug/#SetGCPercent https://golang.org/pkg/runtime/debug/#SetGCPercent
- pjmlp 10y agoThe problem is that Unity doesn't use a modern .NET runtime at all, rather the frozen Mono version from back when the Mono developers where still working for SuSE.
- forrestthewoods 10y agoI've never been more careful to avoid any allocation as I have been in Unity. I had fewer memory concerns in C++ for crying out loud.
- ChrisClark 10y agoSeriously! Once they've fully upgraded .NET and the GC, we'll all sigh in relief.
- psyc 10y agoI would 10,000x rather have to match new with delete (big deal) than to maintain the revolting unidiomatic contortions I'm obligated to do to outwit the GC.
- JoeAltmaier 10y agoThis. Times 100,000
- forrestthewoods 10y agoAgreed x10000. For VR we must maintain strictly zero garbage generation. Which is really damn hard in a language built on the assumption of GC.
- CyberDildonics 10y agoIn modern C++ you don't even have to do that.
- psyc 10y agoFor anyone else who's in this hell, this is the best reference I know of about how you have to write C# when the GC hates your data: http://stackoverflow.com/a/14277068 http://stackoverflow.com/a/14277068 tl;dr - "arrays of structs are really the only bulk storage method available in C#"