PCC reordering idea (and probably branch)

Allison Randal allison at parrot.org
Thu Mar 15 17:14:56 UTC 2012


On 03/15/2012 03:17 AM, Vasily Chekalkin wrote:
> Hello.
> 
> I have some idea about reordering of how PCC works with CallContexts.
> At the moment CallContext created by Parrot_pcc_build_signature on
> caller side and stored inside current CallContext. This is most
> unnatural way of calling Subs and lead as to quite few issues:
> 
> 1. We don't always need fresh CallContext on callee side. For example
> C functions/methods doesn't have to have any.
> 2. Corollary of 1 is increased pressure on GC.
> 3. Corollary of 1 that Sub PMC (and inherited PMCs such as Coroutine,
> Continuation, etc) can create CallContext and storage for registers in
> single call. Which is "suboptimal" (i.e. crappy slow).
> 
> I want to change it other way around:
> 1. Caller fills params in current CallContext.
> 2. Callee creates new CallContext (if needed).
> 3. Callee unpacks params from parent CallContext.
> 
> After implementing this we can optimize CallContext creation to
> allocate storage for registers in single call.

This approach is not thread-safe. There's a very good reason for keeping
all data relevant to the call contained within the CallContext for that
call.

The main solution for the performance problem is to replace the GC with
a reasonably performant modern implementation. Another improvement would
be to make CallContexts lazy, so storage for registers isn't allocated
until it's absolutely needed (in some cases, never). Polymorphism can
help too, it may be appropriate for calls to C functions to use a much
simpler CallContext that respects the same interface as the standard one.

Allison


More information about the parrot-dev mailing list