guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gc-phobia


From: Thomas Bushnell, BSG
Subject: Re: gc-phobia
Date: 01 Nov 2001 10:08:14 -0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Michele Bini <address@hidden> writes:

> While the inability to explicitly free a cons cell is irrelevant, as
> you could eventually adapt your algorithm to reuse it, this seems not
> to be possible with boxed data types, like floating point numbers.
> (hmm, maybe i am missing something here).  During heavy numerical
> processing a considerable amount of time may be spent gc'ing
> expecially when the heap is large (not to mention when part of it lies
> in a swap area).

You seem to thing gc is a big miss.  But actually it's a big gain.
The cost of keeping track of which objects you can reuse, which
objects you can free, is generally *higher* than the cost of having gc
take care of it automatically.

> For instance, a closure compiler could safely rewrite:
> (< (+ (* a a) (* b b)) (+ (* c c) (* d d)))
> into (< (+! (* a a) (* b b)) ...
> or (let loop ((a 3.0)) (loop (* a 1.618)))
> into (let loop ((a 3.0)) (loop (*! a 1.618)))
> (and the latter example could run without waking up the gc).

Yes, that's all certainly true.  That's all under-the-hood
optimization.  Such optimizations are perfectly fine.  But programmers
shouldn't have things like +! in their standard toolkit; that's error
prone.

> (BTW, i am just not authoritative enough to advocate anything, :) i am
> actually trying to figure out the viability of different approaches)
> This was actually meant to be used only in performance critical
> code sections, but now i see that you can just reuse allocated objects
> by employing destructive functions instead, if you really want to.

Even then, it's better to just use GC.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]