Live data from Hacker News

Watching Go's new garbage collector move through the heap

theconsensus.dev

41–48 of 48 posts

Re: Watching Go's new garbage collector move through the heap

#41
post #38
post #28

Earlier quoted context omitted.

> Unity is still stuck with the worst possible GC (Boehm) for the foreseeable future. How are we measuring "worst possible" here? Unity's GC is unique in that it has an incremental marking phase. The most important thing in a unity application is frame latency, not raw GC throughput. If you are generating so much garbage every frame that the incremental collector falls behind, that's probably on you.

A Jurassic GC introduced in Mono, that due to Unity not wanting to pay Xamarin for updates, meant it was mostly frozen in the days of Unity/Xamarin early collaboration. Unity preferred to go down the route of HPC#, Burst compiler and IL2CPP, and is still maybe one to two years to fully migrate to modern .NET. Meanwhile in Redmond, Mono is almost gone, with CoreCLR already in preview for mobile platforms, https://devb…

> Unity preferred to go down the route of HPC#, Burst compiler and IL2CPP, and is still maybe one to two years to fully migrate to modern .NET.

They're replacing Mono with CoreCLR in Unity 7 which is Q1 2027. Somehow they're also doing this with no breaking changes too - even though they previously announced breaking changes due to the obvious differences between the two runtimes.

Also, they have already said there are no plans to change the GC used by IL2CPP builds so it will keep using Boehm.

Re: Watching Go's new garbage collector move through the heap

#42
post #17

Earlier quoted context omitted.

Redis uses jemalloc by default, if I recall correctly, but its hostility to the way systems actually work arises from the way that it forks, then changes one bit on every page in the entire virtual space, which causes a lot of kernel work to support copy-on-write by blowing up huge pages into smaller pages. That's what happens when your program is antagonistic to the way the machine actually works.

> then changes one bit on every page in the entire virtual space Yeah that sucks. Naively implemented garbage collectors have the same problem: they put the live and mark bits in the object itself which spreads those bits all over the address space. This leads to the garbage collector touching every single page when it scans and writes all of those bits. The proper solution is to allocate separate bitmap pages. This…

I've always struggled a bit with the fact that "machines want SoA but readability/clarity/etc is easier with AoS". And wonder if it would be possible for a language to have the code representation be AoS but the implementation transparently be SoA.

Re: Watching Go's new garbage collector move through the heap

#43
post #28
post #21

Earlier quoted context omitted.

Can't say I totally agree with the claim that GC is a dealbreaker for games. There are trade-offs either way and games typically need to do things a bit differently to achieve high performance anyway. It is, however, a strong benefit of Godot over Unity because Unity is still stuck with the worst possible GC (Boehm) for the foreseeable future.

> Unity is still stuck with the worst possible GC (Boehm) for the foreseeable future. How are we measuring "worst possible" here? Unity's GC is unique in that it has an incremental marking phase. The most important thing in a unity application is frame latency, not raw GC throughput. If you are generating so much garbage every frame that the incremental collector falls behind, that's probably on you.

> How are we measuring "worst possible" here?

The garbage collectors used by both .NET and Mono (since 2013) are precise, concurrent, and compacting. They know exactly what memory locations are GC references, scans them while the game is still running, and moves objects in memory to fix fragmentation. Pause times are kept short because heavy work is done on a background that.

Unity's GC is conservative and incremental. It does not know what addresses are GC references so it has to scan everything that could be a GC reference. It's incremental which is nice but means you're expected to trade a few milliseconds of your frame budget for the GC to run. Being conservative means a chunk of your budget is spent scanning memory locations that aren't GC references. By default it uses the time spent waiting for vsync to run but not everyone plays with vsync enabled and lower spec systems have less room there so they end up running worse.

Re: Watching Go's new garbage collector move through the heap

#44
post #25
post #7

Excellent optimization technique: manually copying objects to a new slice so they don't prevent the GC from releasing memory by sitting right in the middle of a page it intends to free.

That's what every "copying GC" does. https://www.cs.cornell.edu/courses/cs312/2003fa/lectures/sec...

Of course, but Go's GC doesn't compact or relocate the objects still in use in the middle of a page (which means that page can't be released to the OS) until you manually copy those surviving objects out, freeing up the page they left behind.

Re: Watching Go's new garbage collector move through the heap

#45
post #41
post #38

Earlier quoted context omitted.

A Jurassic GC introduced in Mono, that due to Unity not wanting to pay Xamarin for updates, meant it was mostly frozen in the days of Unity/Xamarin early collaboration. Unity preferred to go down the route of HPC#, Burst compiler and IL2CPP, and is still maybe one to two years to fully migrate to modern .NET. Meanwhile in Redmond, Mono is almost gone, with CoreCLR already in preview for mobile platforms, https://devb…

> Unity preferred to go down the route of HPC#, Burst compiler and IL2CPP, and is still maybe one to two years to fully migrate to modern .NET. They're replacing Mono with CoreCLR in Unity 7 which is Q1 2027. Somehow they're also doing this with no breaking changes too - even though they previously announced breaking changes due to the obvious differences between the two runtimes. Also, they have already said there a…

Yeah, but will they deliver this time?

Apparently the team has been affected multiple times during the various layoffs.

Unity has been both a blessing for .NET adoption on the games industry, and also pain, given that many equate .NET with their Unity experience.

Re: Watching Go's new garbage collector move through the heap

#46
post #45
post #41

Earlier quoted context omitted.

> Unity preferred to go down the route of HPC#, Burst compiler and IL2CPP, and is still maybe one to two years to fully migrate to modern .NET. They're replacing Mono with CoreCLR in Unity 7 which is Q1 2027. Somehow they're also doing this with no breaking changes too - even though they previously announced breaking changes due to the obvious differences between the two runtimes. Also, they have already said there a…

Yeah, but will they deliver this time? Apparently the team has been affected multiple times during the various layoffs. Unity has been both a blessing for .NET adoption on the games industry, and also pain, given that many equate .NET with their Unity experience.

I have my doubts! I work on Rust (the video game) and we're excited to see how much better performance will be on CoreCLR. However, we were confused by the switch from "Mono replaced with CoreCLR with these breaking changes Unity 6.8" [1] to "Mono replaced with CoreCLR with no breaking changes in Unity 7 [2], with Unity 6.8 off the roadmap [3]".

[1] https://discussions.unity.com/t/path-to-coreclr-2026-upgrade...

[2] https://unity.com/releases/unity-7

[3] https://unity.com/roadmap

Re: Watching Go's new garbage collector move through the heap

#47

Earlier quoted context omitted.

> then changes one bit on every page in the entire virtual space Yeah that sucks. Naively implemented garbage collectors have the same problem: they put the live and mark bits in the object itself which spreads those bits all over the address space. This leads to the garbage collector touching every single page when it scans and writes all of those bits. The proper solution is to allocate separate bitmap pages. This…

I've always struggled a bit with the fact that "machines want SoA but readability/clarity/etc is easier with AoS". And wonder if it would be possible for a language to have the code representation be AoS but the implementation transparently be SoA.

Pretty old, but a good example of how such an abstraction works: https://github.com/ExaScience/arrow-street

Re: Watching Go's new garbage collector move through the heap

#48
post #46
post #45

Earlier quoted context omitted.

Yeah, but will they deliver this time? Apparently the team has been affected multiple times during the various layoffs. Unity has been both a blessing for .NET adoption on the games industry, and also pain, given that many equate .NET with their Unity experience.

I have my doubts! I work on Rust (the video game) and we're excited to see how much better performance will be on CoreCLR. However, we were confused by the switch from "Mono replaced with CoreCLR with these breaking changes Unity 6.8" [1] to "Mono replaced with CoreCLR with no breaking changes in Unity 7 [2], with Unity 6.8 off the roadmap [3]". [1] https://discussions.unity.com/t/path-to-coreclr-2026-upgrade... [2]…

I guess fingers crossed, then. :)
Post reply on HN