Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1620 (closed enhancement: wontfix)

Opened 10 years ago

Last modified 8 years ago

Naive: a new GC implementation

Reported by: llucax Assigned to: kris
Priority: major Milestone: 2.0
Component: Core Functionality Version: 0.99.8 Sean
Keywords: Cc: llucax@gmail.com

Description

I've finished my Naive Garbage Collector implementation. From the Naive GC documentation:

The idea behind this implementation is to document all the bookkeeping and considerations that has to be taken in order to implement a garbage collector for D.

The garbage collector algorithm itself is extremely simple so focus can be held in the specifics of D, and not the algorithm. A completely naive mark and sweep algorithm is used, with a recursive mark phase. The code is extremely inefficient in order to keep the code clean and easy to read and understand.

It has some minimum testing but it's very far from being exhaustively tested, and thus code reviewing and testing is welcome.

The code is attached, but can be viewed on-line too.

I hope it can be included in Tango.

Attachments

naive-0.9.tar.gz (13.7 kB) - added by llucax on 04/27/09 01:39:54.

Change History

04/27/09 01:39:54 changed by llucax

  • attachment naive-0.9.tar.gz added.

(follow-up: ↓ 2 ) 04/27/09 14:39:06 changed by larsivi

Hi Luca!

I appreciate the contribution, but I'm a bit curious as to what should be the reasoning for including it in Tango. What is the use case?

I understand that the naive GC is good for understanding GC mechanics, but is there a "real" program that would benefit from using it? The current GC in Tango is already considered basic, so a naive one doesn't appear to add much.

Also, with the inclusion of more GC's, there would preferably have to be a mechanism in place to easily choose one or the other.

(in reply to: ↑ 1 ) 05/19/09 17:07:49 changed by llucax

  • type changed from defect to enhancement.

Replying to larsivi:

Hi Luca!

Hi, Lars!

I'm sorry for the delay, I never received the e-mail notification on the reply to the bug-report, I guess my anti-spam eat it... =/

I appreciate the contribution, but I'm a bit curious as to what should be the reasoning for including it in Tango. What is the use case?

I think none.

I understand that the naive GC is good for understanding GC mechanics, but is there a "real" program that would benefit from using it?

I don't think so. I've implemented it merely as documentation. I guess including it in Tango has as much sense as including any other kind of documentation.

The current GC in Tango is already considered basic, so a naive one doesn't appear to add much.

Well, I think the current GC has a simple design, but a complicated implementation. It's really hard to figure out how to write a GC that complies with the Tango interface taking into account all the quirks to be correctly plugged into the runtime (I think the "stub" GC doesn't help with that either).

I'm planning to rewrite the basic GC too, but even if I do that, the implementation has to be optimized, so it will be harder to understand than the Naive GC. The memory layout of the basic GC is not that simple either (is not too complicated, that's true). This is not the case for the Naive GC, which can be horrible in terms of performance and have a trivial memory layout so focus can be made only in the "artifacts" needed to write a new GC implementation.

Also, with the inclusion of more GC's, there would preferably have to be a mechanism in place to easily choose one or the other.

I agree on that. The current mechanism is a little clumsy. Unfortunately I don't have much time to do that now, but who knows, maybe when I'd have to start benchmarking and have to switch frequently between implementation it can take me less time to implement a way to make easier to switch between GC implementations than recompiling all the runtime each time =)

BTW, the version in the git repo has a couple of bug fixes.

05/19/09 22:17:08 changed by fawzi

I was quite busy, but I hope to look at it soon. I thinkt that it will be really interesting when it will be multithreaded, even if naive.

05/21/09 18:56:59 changed by llucax

  • cc set to llucax@gmail.com.

This naive implementation will stay as it is now. Well, not really, I'll add code to get some interesting statistics about the GC. I plan to do this for the Basic GC too, then rewrite the Basic GC to clean it up a little and finally I will make the Basic GC concurrent (that's the plan at least =).

11/29/09 12:19:25 changed by fawzi

  • owner changed from fawzi to kris.

12/02/09 22:30:46 changed by kris

  • milestone changed from 0.99.9 to 2.0.

12/03/09 00:56:08 changed by llucax

There is some obscure bug in this implementation that I can't find. There seems to be loosing references to live data for some reason. I've invested too many time on it without success and, since its utility is very limited, I don't think I will dig into it in a near future.

I don't think 2.0 is very near, but I think I should clarify that just in case ;)

12/03/09 05:21:57 changed by kris

ok, thanks for the update :)

10/21/11 17:34:54 changed by llucax

  • status changed from new to closed.
  • resolution set to wontfix.

The naive collector was abandoned so I don't think there is any use on keeping this issue open.