-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Garbage Collection #206
Comments
Minutes from a Discord discussion on GC:
|
Note that immix-rust is not a reference-counting GC |
Also see Counting Immutable Beans for an implementation of reference counting in the Lean theorem prover. They do some clever things like reusing data structures if the reference count is 1. Though it's really focused on purely functional languages. |
I'd just like to point out the option of a colored-pointer GC like ZGC. While ZGC only works on 64-bit architectures (because it needs the extra bits for colored pointers), it has very short pause times that do not scale directly with heap size. |
If I remember correctly, the immix-rust repository does not implement everything of Immix. Specifically, it does not support compacting the heap if my memory serves me right. For Inko I ended up implementing Immix, including support for compacting the heap. If it's of any use, you can find the code for it here:
I also wrote some documentation on this that may help understand the code a bit better: https://inko-lang.org/manual/virtual-machine/memory-management/ I'm happy to answer any questions about Immix as well 😃 |
@pitaj you can use coloured-pointer gcs on 32-bit platforms if you use the low-order bits for colouring. For example, zgc currently uses only 4 bits for colouring, so if you align every allocation to 16 bytes, the low 4 bits are irrelevant and can be used by gc. |
I'll try to make GC API more generic in: Issue 207 and soon create PR with initial changes to API. |
Lots of interesting thoughts above. We're doing a full re-write of MMTk in Rust. Although our implementation is not yet public (I hope to have it for you soon), you can take a browse at the Java code base on which the Rust re-write is based. They key difference is that the re-write targets multiple VMs and multiple languages. |
I haven't seen Conservative GC be mentioned yet which is what Crystal uses for GC so I'm gonna leave a link here to both: |
Hi folks, I was pointed to this issue by @erlend-sh, after announcing GameLisp yesterday. You might be interested by GameLisp's garbage collector. It's not an exact fit for Mun (because Mun seems to be a much more general-purpose language than GameLisp), but you might be able to borrow some ideas. There's a guide-level explanation here, some basic performance figures here, a detailed technical overview here, and the source code itself is here. Technical summary:
One of the most surprising things I learned while implementing the GC is that, for games, the raw throughput of the garbage collector just doesn't matter very much. GameLisp's algorithm has a lot of room for optimization (especially if I were willing to make heavier use of Let me know if you have any questions! |
Might Dart’s GC be a useful reference for Mun? The two languages seem to have pretty similar design goals. Dart uses a generational GC, like GameLisp. @jmeggitt seems to have been tinkering in this space recently. https://medium.com/flutter/flutter-dont-fear-the-garbage-collector-d69b3ff1ca30 |
Consider looking into the Memory Pool System. It implements a generational GC with bump-pointer allocation. Language integration is much easier than with MMTK (having tried both). Although the library is not very widely known, it is backed by a professional contracting-firm. It is used in production in multiple language implementations (main one is OpenDylan). This project might be worth taking a look at. In addition to bump-pointer allocation and generational collection, it also supports concurrent collection! It is likely to be faster than whatever you can write yourself (unless you put like a ton of effort in it). It is not quite as fast level of MMTK/Java/Go, but can be surprisingly competitive 😄 If you do decide to write a collector yourself, "The Garbage Collection Handbook" is very useful (and exceptionally well written). Downsides on MPS: Also collection is (mostly) concurrent, so your trace functions might be called from other threads (and collections can happen any time, not just at allocations). Because of these two things, Integration is difficult to do unless its in C. The library uses a lot of macro magic. Signal handlers can be tricky to get right in higher-level languages (even Rust) while the macros take care of it in C. Inline allocation is an exception, and is easy to do even in hand-written/JIT compiled assembly. |
Were you trying with the Rust version of MMTk? It looks like the rewrite @steveblackburn was talking about has since gone public, and is being actively developed by @qinsoon & co. |
Luau was released after this discussion started. Since it’s specifically made for games (official language for Roblox modding) it surely shares a lot of design goals with Mun. https://luau-lang.org/performance#improved-garbage-collector-pacing
|
Very interesting read! |
@Techcable I'm keen to hear of your MMTk experience. What language were you porting? Any thoughts on what you found difficult? We have a lively community with a lot of ports underway right now, and some pretty interesting work with new algorithms (outperforming G1 and Shenandoah on OpenJDK now). |
I tried integrating with a Python implementation several months ago. Mostly gave up because writing one by hand seemed to be simpler (definitely not faster). It looks like the implementation and documentation has improved significantly since than. I will have to try again :) |
Some folks here might be interested in participating in this: https://www.reddit.com/r/rust/comments/vpq6yn/user_study_interest_in_a_rustlike/ |
@erlend-sh I called off the study because I didn't get much initial interest (only a handful of survey responses) to be able to perform a meaningful study. 😐 |
Ah, too bad. In any case, I think Mun is highly relevant to what you're thinking about :) (Admins, feel free to delete these last comments.) |
https://github.com/kyren/gc-arena by @kyren might be a good fit. |
Currently, the Mun runtime defaults to a mark & sweep garbage collector (henceforth GC). This a relatively simple implementation of a GC, that serves as a good proof of concept. However, going foreword we need to mature our GC story.
Goals
[discussion A] What metrics/use cases are important to benchmark?
The text was updated successfully, but these errors were encountered: