develooper Front page | perl.perl6.internals | Postings from June 2002

Stack and GC

Thread Next
From:
Melvin Smith
Date:
June 19, 2002 21:31
Subject:
Stack and GC
Message ID:
5.1.0.14.2.20020620001554.0376a578@pop.mindspring.com
Just some notes, maybe Dan will read this on the road.

While working on the first (experimental) cut at continuations
and copy-on-write stacks, I notice that a stack_chunk involves
3 allocation calls. This is expensive (I think) for stack copying.

1) The chunk
2) The buffer header
3) The buffer

(1) Isn't yet under GC control, but will be soon. It looks like we need
to try to reduce the above into 2 pieces at most. Possibly we don't
even need a buffer header if/when the collector knows about Stack_chunks,
but right now I don't want to fiddle with more than I need to for 
proof-of-concept.

Also, saving an Interp context is currently expensive. I've made a 
Parrot_Context
struct which contains all of the stacks and register frames. This probably
needs to be included inline to the Parrot_Interp struct so we can just
save/restore context with a single memcpy(&interp->ctx, &saved->ctx, ...).

So right now, a continuation capture involves:

save_context(interp, cc->ctx)
stack_mark_cow(interp->user_stack)
stack_mark_cow(interp->control_stack)
....
and the same for reg frame stacks I suppose

Given that it seems capturing and restoring a context is the most
expensive part, should we make default routines lightweight (execute
on caller stack rather than getting their own) and only make
continuations and co-routines take most of the penalty?

-Melvin


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About