partcl pmc usage.
Will Coleda
will at coleda.com
Thu Jan 1 00:32:13 UTC 2009
Of interest:
{{{
$ cat foo.pir
.include 'interpinfo.pasm'
.macro count()
collect # free up any PMCs we can.
current = interpinfo .INTERPINFO_ACTIVE_PMCS
diff = current - previous
print diff
say " more PMCs created."
previous = current
.endm
.sub main :main
.local int current, previous, diff
previous = 0
.count()
bar()
.count()
bar()
.count()
bar()
.count()
bar()
.count()
bar()
.count()
bar()
.count()
bar()
.count()
.end
.sub bar
.end
}}}
outputs:
{{{
$ ./parrot foo.pir
1589 more PMCs created.
52 more PMCs created.
52 more PMCs created.
52 more PMCs created.
52 more PMCs created.
52 more PMCs created.
52 more PMCs created.
52 more PMCs created.
}}}
I note the initial number seems to have decreased, but each invocation
of a do nothing subroutine with no actual parameters passed anywhere
results quite an accumulation of PMCs each round.
I stripped this down even further:
{{{
$ cat foo.pir
.include 'interpinfo.pasm'
.sub main :main
.local int current
current = interpinfo .INTERPINFO_ACTIVE_PMCS
say current
current = interpinfo .INTERPINFO_ACTIVE_PMCS
say current
current = interpinfo .INTERPINFO_ACTIVE_PMCS
say current
current = interpinfo .INTERPINFO_ACTIVE_PMCS
say current
current = interpinfo .INTERPINFO_ACTIVE_PMCS
say current
.end
}}}
results in:
{{{
1588
1605
1622
1639
1656
}}}
So, doing mostly nothing, our PMC usage is increasing by 17 just from
doing a say (you can verify that it's the say by doubling up on the
each opcode; calling interpinfo 2x results in the same output; calling
say twice doubles each number, and causes the difference to go to 34
when it does change.)
Digging a bit, I see that say eventually invokes Parrot_PCCINVOKE,
which drags the calling conventions back into it.
Could we possibly free some PMCS used in the call once the invocation
has happened? I presume that CTX_REG_PMC in Parrot_PCCINVOKE is
holding on to them.
--
Will "Coke" Coleda
More information about the parrot-dev
mailing list