[mercury-users] Structure reuse

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jul 15 09:07:00 AEST 2003


On 14-Jul-2003, Michael Day <mikeday at yeslogic.com> wrote:
> 
> I am struggling to reduce the memory usage of a Mercury program that
> iteratively updates a tree structure over several passes.
> 
> Mercury does not yet appear to take advantage of structure reuse, so it
> seems that the structure is being copied at each iteration, when it could
> simply be updated in-place. This is bad.

Are you really trying to reduce the program's space usage, or just to
improve its locality and speed?

Generally structure reuse optimization will only improve the speed of
the program, not its space usage.  The reason is that the memory which
structure reuse reuses is garbage anyway; if structure reuse optimization
is not done, the memory will be reclaimed automatically by the garbage
collector.  The advantage of structure reuse is that it increases speed
by improving locality and by making garbage collections less frequent.

(The only exception to this is that when using a conservative garbage
collector, it is possible that memory which is garbage is sometimes
not reclaimed.  However, this effect is likely to be very small unless
the program's data occupies a large fraction of the address space,
which is very rare on most current machines.)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list