[mercury-users] Exceptions and unique modes

Peter Ross peter.ross at miscrit.be
Fri Mar 2 01:13:54 AEDT 2001


On Fri, Feb 23, 2001 at 11:11:56AM +1100, Peter Schachte wrote:
> On Fri, Feb 23, 2001 at 10:05:08AM +1100, Thomas Conway wrote:
> > On Thu, Feb 22, 2001 at 10:45:32PM EST, Ralph Becket wrote:
> > > >From Peter Ross on 22/02/2001 11:41:32
> 
> > > > :- type t
> > > >     --->    f(int)
> > > >     ;       g(int, int).
> > > > 
> > > > No matter what you initialise this type to you need to make sure that
> > > > you allocate 2 words so that you can possibly hold the g constructor at
> > > > some later date.
> 
> There are lots of ways to reuse memory.  One way would be to have a free
> list for each size of structure.  when an f/1 term becomes free, it is
> placed on the chain of free 1-word free cells.  When a g/2 term needs to be
> allocated, it is taken from the 2-word free list.  Unless it's mostly the
> case that when replacing an f/1 term with a g/2 term the first argument is
> usually the same, I can't see how there'd be much benefit to allocating 2
> words for every f/1 term just so you can convert between them in place.
> 
Note this is only an issue for when we want the same memory address to
refer to some threaded unique object, so we can get a handle back on it
when an exception is thrown.  It is not an issue for structure reuse in
general.

Regards your free list idea, I experimented with implementing this quite
a while ago as a cheap structure reuse optimization, basically you keep
a small cache of cells which can be reused (how big the cache should be
is a matter of research) and you check this cache for any cells before
asking for another cell on the heap.

I need to one day go back and finish instrumenting this code and do some
experiments to see how well it works in real life.

Pete
--------------------------------------------------------------------------
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