I'm trying to make an Arc compiler in c as my part-time project and I've built an two-phase mark-sweep gc algorithm. Now I decide to make a stronger one but have to face choices such as tri-color. Since I know little about garbage collection, I would really appreciate what's your choice and why you choose it. Thank you!
BTW: if you're interested you may take a look at the source code at https://github.com/wsxiaoys/carc/tree/dev
another idea: you could go on the Racket dev email list (http://racket-lang.org/community.html) and say "as a learning experience I've implemented a gc for a small Lisp and was thinking about what to do next such as perhaps trying a tri-color algorithm. I'm curious what gc algorithm you're using for Racket and why you chose it over other alternatives?"
Thanks for advices, I've read some papers on this topic and will take a deep searching into different scheme/lisp groups in following days.
For now I decide to refactor carc to an byte-code one and use the new gc mechanism from the scratch :P
If you'd like, something that would be helpful to us for you to keep an eye out for while you're looking is that we'd like to find a runtime (or learn how make a runtime) which:
- runs on multiple cores, AND
- supports full call-with-current-continuation, tail call optimization, and mutable lists
Our current options include:
- Racket, which can run on multiple cores, but only supports mutating lists within a single core, and
- the JVM, which does support mutating data structures by multiple cores, but doesn't natively support full continuations or tail call optimization.
ok, I think in order to give advice I'll need to understand your goals better. (After all, I could say "you should do X", but if X doesn't lead you to accomplishing something you want, than my advice wouldn't be very useful).
When you say you want to make an Arc compiler, do you mean that you that you'd like to create a compiler that implements all of Arc, and so it could be used for example to run a news forum like Hacker News on?
Or, are you for example primarily interested in learning, and if so, what would you like to learn?
Any goal you have is valid, but it's relevant for your question about gc. For example, one of the choices you have is whether to not support threads, or to support threads but only on a single core, or to support threads on multiple cores. Which one you choose has a major impact on how to approach gc: it determines both what algorithms you can use and also what algorithms you want to use.
This project starts with the purpose of making an S-expression language which can be easily embedded into another project.
Since I really like arc's sugar-syntax, I would like to implement all language specification which arc has, and make it extensible and easy to embed.for above reasons, I would rather do not take any kernel-level threading techniques, but with some user mode thread and in-background dispatcher to support async socket io. Currently, it have tail recursion optimization, continuation, macro and a mark&sweep garbage collector.
Overall, you're right, it's primarily a project of learning how to make a language.
Just so I understand your terminology, by "user mode thread" do you mean that you will have threads at the Arc language level, and that they will be implemented by your runtime by having your C code itself switch between threads? (And thus the Arc language level threads will all run inside of one operating system thread?)
One thought that occurs to me is that the next thing that might be most useful is to have a way to easily see the performance of the garbage collector in a program you're running. Then when you notice "oh look, Arc is allocating a large number of short lived small objects" or whatever you can tune your garbage collector (or look for a gc algorithm) that works well with the pattern you're seeing.
I don't know enough myself about the different gc algorithms to make a suggestion. All I could offer is a wish-list of what we'd like Arc gc to be able to do, which perhaps you might find useful if you went to an algorithms forum or mailing list and found out what gc algorithms might be able to do that.
I'm not able to look at your source code because your copyright notice (it looks like maybe it came from a template?) says "all right reserved" without a notice of the code being released under an open source license. If your code is derived from Arc then you may need to release it under the Perl Artistic Licence (the same as Arc); or, if it's not, but you'd like to release it under an open source license, then the MIT License (http://opensource.org/licenses/mit-license) is a good choice to consider.
It's right since the header files are all created in Xcode 4 with the default template. I will make it under an open source license after reading both licenses. Thank you for the advices!