September 11, 2010
No worries, I'm just investigating. I don't need real-time performance any time soon. :)

I have seen a pluggable .NET system that has to run in real-time. If that's possible in .net, I'm sure it will be possible in D (if it isn't already).

Thanks for all your input!

On Sat, Sep 11, 2010 at 5:23 AM, Jonathan M Davis <jmdavisprog@gmail.com> wrote:
>
> However, I would point out, as I said before, that on today's systems, odds are that you will get properly realtime performance in spite of the GC and any collection cycles that it runs. D's GC being more primitive may not do as good a job with that as others - like Java's or .NET's - but I'm not sure that you want to complicate your program worrying about the GC unless you profile it appropriately and find out that you need to. Certainly, as D matures, it should become less of an issue.
>
> - Jonathan M Davis
>
September 11, 2010
Jonathan M Davis:

> In any case, if you're looking to avoid GC collection cycles, it sounds like std.gc.disable() and std.gc.enable() will help. But remember that that will increase the odds that it will have to allocate more memory from the OS, which isn't cheap either. It's almost certainly cheap_er_, but it still wouldn't be cheap. Also, with D's current GC, that means that your program will use more memory overall.

From my tests, the disable() is useful when you want to just build a data structure, so when you need to quickly allocate many small parts, and then you call enable() when the data structure is done. This avoids many possible collections in the middle, and may lower the running time significantly.

Recently the Python GC has introduces some similar automatic optimizations:
http://docs.python.org/dev/whatsnew/2.7.html#optimizations
The garbage collector now performs better for one common usage pattern: when many objects are being allocated without deallocating any of them. This would previously take quadratic time for garbage collection, but now the number of full garbage collections is reduced as the number of objects on the heap grows. The new logic only performs a full garbage collection pass when the middle generation has been collected 10 times and when the number of survivor objects from the middle generation exceeds 10% of the number of objects in the oldest generation. (Suggested by Martin von Löwis and implemented by Antoine Pitrou; issue http://bugs.python.org/issue4074 .)

I don't know of something similar, may be done automatically by the current D GC.

Bye,
bearophile
1 2 3
Next ›   Last »