[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tc16_allocated (was: guile/guile-core/libguile init.c)
From: |
Mikael Djurfeldt |
Subject: |
Re: tc16_allocated (was: guile/guile-core/libguile init.c) |
Date: |
02 Sep 2000 20:48:49 +0200 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 |
[I'm including Matthias Jacob on the thread.]
Michael Livshin <address@hidden> writes:
> Mikael Djurfeldt <address@hidden> writes:
>
> > In the old GC scheme, a cell has three phases in its life: first it is
> > a free cell, then an allocated cell, and, thirdly, a real cell. Each
> > phase requires at least one store to memory. And, since we now have
> > multiple freelists, the free phase can actually be repeated,
Michael, could you please explain what I meant by this last sentence?
> > so
> > there's a waste of at least one (+ repeated free phases) store to
> > memory per cell used.
> >
> > Also, the allocated phase is entered too late to work in pre-emptive
> > multithreading, because a thread might be interrupted just before
> > storing scm_tc16_allocated into a cell, and next thread might trigger
> > GC.
> >
> > I now suggest the following change to be applied to the new GC scheme:
> >
> > * Remove the scm_tc16_allocated phase. If a cell isn't "real", it is
> > scm_tc_free_cell.
>
> good goal.
>
> > * Don't collect free cells during the sweep, just let them stay in
> > their freelist or in their cluster.
>
> bad idea. after several GC's you'll end up with a freelist that jumps
> all over the place. *not* good.
>
> it also makes implementing lazy sweep harder.
Not good, indeed.
> so, I have two ideas for improving the situation:
>
> 0) the simple-minded idea.
>
> currently, `scm_mark_locations' doesn't mark free cells for fear of
> false positives.
>
> I think it's worthwhile to let them be marked, and see if false
> positives really are problematic (I think not, but people with real
> applications should try and see).
>
> if we let free cells be marked, then the "allocated" phase isn't
> needed at all.
>
> 1) the slightly more sophisticated idea.
>
> we let `scm_mark_locations' mark a free cell only if it's close to
> the top of the stack, and not mark it otherwise.
>
> the idea is that cells should be initialized "as soon as" they are
> SCM_NEWCELL'ed, i.e. in the same C stack frame. I think it's
> reasonable to require that if the cell isn't initialized in the
> same C function in which SCM_NEWCELL was called, then the cell may
> be GC'ed.
>
> [ determining the precise meaning of "close to the top of the
> stack" looks problematic, though. ideas welcome. ]
The first idea is simpler, so it is intrinsically better. The second
idea is better only if the first has some problem. I don't see how it
could be a problem if a few free cells are marked by mistake.
Could it?