4 ms·
Agreed, for most real world softwares, the cost of GC is irrelevant. But there are still some programs like databases or game engines where the cost can start a
by shivanshuag 2mo ago
Agreed, for most real world softwares, the cost of GC is irrelevant. But there are still some programs like databases or game engines where the cost can start adding up. That's when you measure and optimize.
- pjmlp 2mo agoYet the three major game engines Unreal, Unity and Godot all have a GC on their infrastructure, and Capcom is quite happy with their .NET fork on RE Engine. Also every single graphics application that uses Metal or DirectX, relies on reference counting as GC algorithm.
- slopinthebag 2mo agoI’m sure those three engines have had no issues with performance whatsoever right? Oh shit…
- izacus 2mo agoDo you have any source taking about GC caused performance issues in those engines?
- slopinthebag 2mo agoToo many to post, you can just google “{engine} gc spike” for example. Heck, there is a whole cottage profession of experts who get called into fix GC related performance issues with Unity.
- jayd16 2mo agoSo are you saying this cottage industry achieves success or the industry formed around an impossible task? A cottage industry is built around making rocks look good too. Is that an indicator that games are good or bad at making rocks?
- izacus 2mo agoI work in performance optimization (I guess the cottage industry you're talking about?) and GC issues haven't been close to top 10 problems in any of the engines or OSes we've dealt with lately, so I'm wondering what you're on about there. Can you quantify and elaborate more how much GC is an issue for something like Unreal engine?
- pjmlp 2mo agoI am sure that many of the issues were a skills issue as well.
- jmull 2mo agoGame developers are always trying to push the boundaries. The only game engines without performance issues are ones hardly being used.
- slopinthebag 2mo agoThere is a difference between pushing more polygons or higher resolution, and trying to fix stutters caused by the GC…
- pjmlp 2mo agoAlternatively they could be fixing stutters caused by using malloc() on the wrong place.
- slopinthebag 2mo agoMuch rarer and easier problem to deal with. Besides, bump allocators are widely used in games programming, which essentially eliminates this entire class of performance issues. Good luck using one in a GC'ed language.
- jmull 2mo agoThere isn’t though. Garbage collectors aren’t magical black boxes with no levers, and you can use them how you like. You address performance problems relating to GC the same as you do anything else: measure, analyze, optimize, repeat.
- slopinthebag 2mo agoThe difference is that you don't need to be pushing the boundaries at all to get into trouble with the GC. All you have to do is use it as it's intended.
- deleted 2mo ago[deleted]
- jayd16 2mo agoWhat engine do you recommend?
- slopinthebag 2mo agoDepends on the game
- dismalaf 2mo agoI mean, you can always add enough triangles, shaders, entities, etc... to make any engine slow to a crawl... Anything that pushes state of the art will have more performance issues than something that doesn't.
- marcosdumay 2mo ago> That's when you measure and optimize. How do you "optimize" the GC away after you wrote your entire database server in a language that uses it?
- ApolloFortyNine 2mo agoIt's incredibly in common in game development, C# has a lot of features you can take advantage for this. But the most naive example any language supports is simple object pooling. Then more fancy, zero allocations tasks in C# https://github.com/cysharp/unitask https://github.com/cysharp/unitask
- jmull 2mo agoGC languages typically have features of the language and/or standard library that make GC the default, not the only option.
- marcosdumay 2mo agoWhat doesn't save you from having to rewrite the entire system. (Even though, no, that's not typical. That's a tiny minority of them.)
- jmull 2mo agoNot sure I understand the question, but it generally works like this: Once you measure, you'll find a small fraction of the code is taking a large fraction of the time. When you zoom in on trouble-spots you may find, e.g. that the GC is taking the time (or you may find something else entirely is taking the time). If it's the GC, you might look and see, e.g., that it's spending its time tracing the objects in the 100K node graph you're creating several times a second, and realize you could, e.g., create it once and simply keep reusing it. Perhaps it might be as simple as using removeAll(keepingCapacity: true) instead of removeAll() (a Swift example). The superficial details differ, but you generally just want to understand what the GC is working so hard on and lighten its load. If you haven't been measuring and optimizing throughout, there are almost certainly easy-to-pluck, low-hanging fruits, ripe for the taking.
- slopinthebag 2mo agoThis assumes that you’re only ever running a single software at a time. Sure, 2-10x slower/memory consumption might not matter in a vacuum, but when every software is like this, you get machines that feel slower than they did 2 decades ago.
- jayd16 2mo agoDid you "Agreed" your own blog?
- Sha1rholder 2mo agoThis is getting ridiculous.