Remix.run Logo
shivanshuag 4 days 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.

jayd16 2 hours ago | parent | next [-]

Did you "Agreed" your own blog?

Sha1rholder an hour ago | parent [-]

This is getting ridiculous.

pjmlp 4 hours ago | parent | prev | next [-]

Yet 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 3 hours ago | parent [-]

I’m sure those three engines have had no issues with performance whatsoever right?

Oh shit…

jmull 3 hours ago | parent | next [-]

Game developers are always trying to push the boundaries. The only game engines without performance issues are ones hardly being used.

pjmlp 3 hours ago | parent | prev | next [-]

I am sure that many of the issues were a skills issue as well.

jayd16 2 hours ago | parent | prev | next [-]

What engine do you recommend?

izacus 3 hours ago | parent | prev | next [-]

Do you have any source taking about GC caused performance issues in those engines?

slopinthebag 2 hours ago | parent [-]

Too 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 2 hours ago | parent [-]

So 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?

dismalaf 30 minutes ago | parent | prev | next [-]

I 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.

2 hours ago | parent | prev [-]
[deleted]
marcosdumay 3 hours ago | parent | prev | next [-]

> 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 3 hours ago | parent | next [-]

It'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

marginalia_nu 2 hours ago | parent | prev | next [-]

Object pooling and bump allocators using persistent scratch buffers, mostly. The latter what you'd use for read buffers in I/O intensive applications like databases and the like.

pjmlp an hour ago | parent | prev | next [-]

Starting by using a GC language that is strongly typed, compiles to native code, supports value types, memory pools/arenas if required, which provides best of both worlds.

Where GC means any kind of GC algorithm from CS point of view.

jmull 3 hours ago | parent | prev | next [-]

GC languages typically have features of the language and/or standard library that make GC the default, not the only option.

marcosdumay 2 hours ago | parent [-]

What 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 2 hours ago | parent [-]

Not 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.

jayd16 2 hours ago | parent | prev [-]

Lots of ways but an obvious and generic answer is to use pooling.

slopinthebag 2 hours ago | parent | prev [-]

This 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.