Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

c - Running Boehm GC in multiple threads independently

I'm experimenting with writing some bindings to the Boehm GC for Rust.

Some background: Rust is designed to be a high-concurrent language, and a result of this design is having the ability to statically restrict GC pointers to within the threads in which they were allocated (that is, a GC pointer allocated in thread x can never be kept alive (or even referenced at all) by another thread).

Hence, I wish to drive Boehm to capitalise on this for performance as much as possible:

  1. thread-safe, so I can allocate and collect from multiple threads
  2. stop-as-little-as-possible collections (i.e. just the current thread), other threads can keep running because they can't possibly interfere with anything relevant to the GC pointers outside of themselves
  3. preferably, entirely thread-locally with no synchronisation between the GC "instances" of different threads

1 is easy, but I can't find any facility for 2 and 3. The most important part is 1 & 2 because I want to be able to have threads running in the background, independently of what the other threads are doing (even if they are all allocating and garbage-collecting gigabytes of memory).

(I do know about THREAD_LOCAL_ALLOC & gc_thread_local.h, but that doesn't quite satisfy 3 fully, it just makes it more efficient, but it is still valid to transfer the pointers allocated thread-locally between threads, while I don't need that guarantee.)

question from:https://stackoverflow.com/questions/20921988/running-boehm-gc-in-multiple-threads-independently

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't have an answer about how to do this with Boehm. However, here are two GCs which seem to have enough control and encapsulation to have a totally independent GC context per-thread.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...