[erlang-questions] Deforesting tuple updates

Thomas Lindgren <>
Thu Feb 22 12:14:47 CET 2007


--- Bjorn Gustavsson <> wrote:

> 
> Joel Reymont <> writes:
> 
> > I remember that the update is performed
> destructively when the tuple  
> > is indexed with an integer or something like that.
> I would like to  
> > change this to generally use destructive tuple
> updates.
> > 
> 
> Do you also plan to implement a write barrier in the
> garbage collector
> at the same time? If not, you are likely to get some
> nasty emulator crashes.

For those not into the GC lingo, write barriers are
needed because destructive updates can introduce
pointers from the old generation to the new one; these
must be traced along with all other roots when a minor
collection occurs, or the old generation will point to
garbage. A write barrier registers the old->new
pointer with the GC.

(The following assumes a classic, unshared heaps
implementation.)

An alternate option would be to introduce a
per-process flag to tell the system that all future
collections FOR THIS PROCESS must be major, in effect
using non-generational copying GC locally.

Since there is suddenly just one generation, there is
no need for a write barrier. The flag can be set when
a destructive update occurs, or even at process spawn
time. (The latter would be unsafe if the flag was not
set and destructive updates still used.)

The advantage with this approach is that it's fairly
straightforward to implement. Whether it's a good idea
depends on the program, of course. The cost of GC may
eat the gains, basically.

Best,
Thomas



 
____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited



More information about the erlang-questions mailing list