News for hackers. Stuff that matters.
Re:A comparison of Rust's borrow checker to the one in C# by Traubenfuchs on Thursday October 31, 2024 @05:58AM (#42005139)
> if you invoke GC intentionally at convenient timing boundaries (I.e., after each frame),

Manually invoking GC many times per second is a viable approach?

Re:A comparison of Rust's borrow checker to the one in C# by bob1029 on Thursday October 31, 2024 @09:38AM (#42006787)
It has worked well in my prototypes. There is a reason a GC.Collect method is exposed for use.
Re:A comparison of Rust's borrow checker to the one in C# by smaudet on Thursday October 31, 2024 @01:13PM (#42008935)
At least for this instance you have a good idea which objects are "ripe" for collection. There should be some way to specify "collect these, my infra objects don't need to be".
Re:A comparison of Rust's borrow checker to the one in C# by munificent on Thursday October 31, 2024 @10:40AM (#42007395)
It can be, yes.

You're basically trading off worse throughput for better latency.

If you forcibly run the GC every frame, it's going to burn cycles repeatedly analyzing the same still-alive objects over and over again. So the overall performance will suffer.

But it means that you don't have a big pile of garbage accumulating across many frames that will eventually cause a large pause when the GC runs and has to visit all of it.

For interactive software like games, it is often the right idea to sacrifice maximum overall efficiency for more predictable stable latency.

Re:A comparison of Rust's borrow checker to the one in C# by neonsunset on Thursday October 31, 2024 @11:22AM (#42007825)
This might be more problematic under CoreCLR than under Unity. Prematurely invoking GC will cause objects that are more likely to die in Gen 0 to be promoted to Gen 1, accumulate there and then die there. This will cause unnecessary inter-generational traffic and will extend object lifetimes longer than strictly necessary. Because live object count is the main factor that affects pause duration, this may be undesirable.

It might be more useful to use OSU! approach as a reference: https://github.com/dotnet/runtime/issues/96213#issuecomment-...

OSU! represents an extreme case where the main game loop runs at 1000hz, so for much more realistic ~120hz you have plenty of options.

Re:A comparison of Rust's borrow checker to the one in C# by smaudet on Thursday October 31, 2024 @01:10PM (#42008893)
If you could even just pass an array of objects to be collected or something, this would so much easier.

Magic, code or otherwise, sucks when the spell/library/runtime has different expectations than your own.

You expect levitation to apply to people, but the runtime only levitates carbon based life forms. You end up levitating people without their affects (weapons/armor), to the embarrassment of everyone.

There should be no magic, everything should be parameterized, the GC is a dangerous call, but it should be exposed as well (and lots of dire warnings issued to those using it).

Re:A comparison of Rust's borrow checker to the one in C# by munificent on Thursday October 31, 2024 @04:34PM (#42011221)
> If you could even just pass an array of objects to be collected or something

If you have a bunch of objects in an array that you have a reference to such that you can pass it, then, by definition, those objects are not garbage, since they're still accessible to the program.

Re:A comparison of Rust's borrow checker to the one in C# by smaudet on Thursday October 31, 2024 @04:42PM (#42011301)
Yes. Use a WriteOnlyArray or whatever, Semantics aside though...

There should be some middle ground between RAII and invoking Dispose/delete and full blown automatic GC.