Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:parrot/parrot
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeenan committed Aug 10, 2011
2 parents 3764b88 + 2947ca6 commit 0a4ca49
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 68 deletions.
6 changes: 3 additions & 3 deletions compilers/imcc/imcc.y
Expand Up @@ -1527,10 +1527,10 @@ multi_type:
| STRINGC
{
SymReg *r;
if (strcmp($1, "_") != 0)
r = mk_const(imcc, $1, 'S');
else {
if (strcmp($1, "\"_\"") == 0 || strcmp($1, "'_'") == 0)
r = mk_const(imcc, "PMC", 'S');
else {
r = mk_const(imcc, $1, 'S');
}
mem_sys_free($1);
$$ = r;
Expand Down
6 changes: 3 additions & 3 deletions compilers/imcc/imcparser.c
Expand Up @@ -3864,10 +3864,10 @@ YYSTYPE yylval;
#line 1528 "compilers/imcc/imcc.y"
{
SymReg *r;
if (strcmp((yyvsp[(1) - (1)].s), "_") != 0)
r = mk_const(imcc, (yyvsp[(1) - (1)].s), 'S');
else {
if (strcmp((yyvsp[(1) - (1)].s), "\"_\"") == 0 || strcmp((yyvsp[(1) - (1)].s), "'_'") == 0)
r = mk_const(imcc, "PMC", 'S');
else {
r = mk_const(imcc, (yyvsp[(1) - (1)].s), 'S');
}
mem_sys_free((yyvsp[(1) - (1)].s));
(yyval.sr) = r;
Expand Down
65 changes: 52 additions & 13 deletions docs/dev/profiling.pod
Expand Up @@ -21,33 +21,62 @@ defaults described below.

=head2 Running Code Under the Profiler

<add something here>
In Parrot, profiling capability is provided in the form of a built-in runcore
and is available with any installed version of Parrot. The only condition is
that you be able to run your code as a series of arguments passed directly to
the parrot executable, rather than a "fakecutable" (a native executable that
runs built-in hard-coded Parrot bytecode). If you usually run your code via a
fakecutable such as C<perl6>, you'll need to run C<perl6.pbc> directly instead.
For example, if you run C<./perl6 foo.p6>, instead run C<parrot perl6.pbc
foo.p6>. If your code can run normally when passed to the C<parrot> executable
directly, you can easily profile it.

To profile, add C<-Rprofiling> to the command-line invocation of C<parrot>
before any C<.pbc> files are added, e.g. C<./parrot -Rprofiling perl6.pbc
foo.p6>. Your program will run more slowly and will end with a message such as
PROFILING RUNCORE: wrote profile to parrot.pprof.4251
Use tools/dev/pprof2cg.pl to generate Callgrind-compatible output from this file.

You now have a raw profile of your code.

=head2 Profile Post-processing Tools

<add something here>
The profiling runcore spits out a line-oriented plain-text file which contains
the timing information for each executed instruction and a description of each
context change. This data should be sufficient to determine any information
about the timing of instructions and subs. The format is intended to be
straightforward and amenable to processing by external tools.
C<tools/dev/pprof2cg.pl> is included with Parrot and attempts to read a profile
generated by the profiling runcore and produce a profile which
callgrind-compatible tools (e.g. kcachegrind) can understand.

=head3 Interpreting Post-processed Output

<add something here>
* use callgrind_annotate (include some known-good and useful invocations, plus examples)
* use kcachegrind (results are likely to be buggy)
* don't use wincachegrind (lovely tool, uses xdebug-flavored version of callgrind's format)

=head2 Bugs and Surprises

<add something here>
In theory the output of pprof2cg.pl should be compatible with kcachegrind. In
practice, it isn't. If you have a use case that reliably produces non-sensical
results, talk to cotto on #parrot or file a ticket.

=head2 Manually Post-processing
=head2 Environment Variables

<add something here>
=head3 Generally Useful Variables

=head2 Environment Variables
This section includes environment variables which are likely to be of interest
to developers wishing to profile HLL code.

=over 4

=item C<PARROT_PROFILING_FILENAME>

This determines the full name of the file where the output will be written, if
any. Parrot does not check if the filename exists before opening it for
writing and will happily overwrite any existing files, including previous profiles.
writing and will happily truncate and overwrite any existing files, including
previous profiles.

If no value is specified, Parrot will write to a file named C<parrot.pprof.X>,
where X is the PID of the Parrot process. When the profiling runcore exits, it
Expand All @@ -57,6 +86,13 @@ This variable can also have the special values C<stdout> and C<stderr>. When
either of these values are detected (case-insensitively), Parrot will print its
profiling output the stdout or stderr.

=item C<PARROT_PROFILING_ANNOTATIONS>

This determines whether PIR annotations will be recorded as part of the
profile. Annotations are necessary when profiling HLL code, but will cause the
profiling runcore to run more slowly. By default, they are disabled. Set this
value to enable them.

=item C<PARROT_PROFILING_OUTPUT>

This determines the type of output which will contain the profile. Current
Expand All @@ -67,12 +103,15 @@ to the output file. It is most useful for testing and optimizing the
profiling runcore itself. It is expected to be of little interest to users
wishing to profile PIR and HLL code.

=item C<PARROT_PROFILING_ANNOTATIONS>
=back

This determines whether PIR annotations will be recorded as part of the
profile. Annotations are necessary when profiling HLL code, but will cause the
profiling runcore to run more slowly. By default, they are disabled. Set this
value to enable them.
=head3 Debugging-Related Variables

These variables are intended primarly for testing of the profiling code itself.
You can play with them if you want, but they probably won't help you get any
useful work done.

=over 4

=item C<PARROT_PROFILING_CANONICAL_OUPUT>

Expand Down
44 changes: 3 additions & 41 deletions docs/glossary.pod
Expand Up @@ -248,13 +248,8 @@ be added, or overridden (for instance, the PAST to PIR transformation).
Parrot Design Document: documents that describe the features parrot must
implement.

See also L<< http://github.com/parrot/parrot/docs/pdds/pdd00_pdd.pod.html >>.

=begin html

<a href="http://github.com/parrot/parrot/docs/pdds/pdd00_pdd.pod">pdd00_pdd.pod</a>

=end html
See also L<< Running|http://docs.parrot.org/parrot/latest/html/docs/running.pod.html >> and
L<< PDD 0: Design Document Format|http://docs.parrot.org/parrot/latest/html/docs/pdds/pdd00_pdd.pod.html >>.

=item PGE

Expand Down Expand Up @@ -302,49 +297,16 @@ See also L<"PCT">.

=item Predereferencing

=for comment
XXX This section needs to be edited down.

A bytecode transformation technique which reduces the amount of pointer
dereferencing done in the inner loop of the interpreter by pre-converting
opcode numbers into pointers to their opfuncs, and also converting the register
numbers and constant numbers in the arguments to the ops into pointers.

The original implementation by Gregor Purdy was posted on 2001-12-11. On one
test system, it resulted in a 22% speed increase on a test program with a tight
inner loop.

L<http://archive.develooper.com/perl6-internals@perl.org/msg06941.html>

On 2001-12-18, predereferencing got a speed boost (to about 47% faster than the
regular DO_OP inner loop -- without compiler optimizations turned on). This was
due to an off-list (actually over lunch) suggestion by John Kennedy that
instead of pre-initializing the new copy of the bytecode with NULL pointers, we
pre-initialize it with pointers to a pseudo-opfunc that does the
predereferencing whenever it is encountered.

On 2002-04-11, Jason Gloudon suggested combining aspects of the Computed Goto
Core and the Prederef[erencing] Core.

L<http://archive.develooper.com/perl6-internals@perl.org/msg07064.html>

The week of 2003-02-09, Leopold Toetsch combined Computed Goto and
Predereferencing to produce the CGP core.

L<http://dev.perl.org/perl6/list-summaries/2003/p6summary.2003-02-09.html#Week_of_the_alternative_runloops>

Later, on 2003-02-14, Leopold Totsch and Nicholas Clark combined the JIT and
the Computed Goto Prederef cores to great effect.

L<http://www.perl.com/pub/a/2003/02/p6pdigest/20030216.html>

=item run core

aka run loop, aka runcore. The way Parrot executes PBCs.
See running.pod for a list of available runcores, and how to tell
parrot which one to use.

running.pod: L<< https://github.com/parrot/parrot/parrot/docs/running.pod >>
parrot which one to use. L<< Running|http://docs.parrot.org/parrot/latest/html/docs/running.pod.html >>

=item SMOP

Expand Down
15 changes: 7 additions & 8 deletions docs/pct/gettingstarted.pod
Expand Up @@ -6,14 +6,13 @@ Getting Started with the Parrot Compiler Tools

=head1 DESCRIPTION

This document can be considered your Number One entry point for starting to use
the Parrot Compiler Tools (PCT). As there's a whole lot of acronyms flying
around (see Parrot's glossary at
L<https://github.com/parrot/parrot/blob/master/docs/glossary.pod>),
this document will get you up and running within 10 minutes (that excludes
building Parrot). Once you begin, it's a matter of getting your hands dirty and
get experienced using the tools. Feel free to ask questions in
the #parrot channel on irc.parrot.org .
This document can be considered your Number One entry point for starting to
use the Parrot Compiler Tools (PCT). There will be a whole lot of acronyms
flying around. Consult L<< Parrot's glossary|http://docs.parrot.org/parrot/latest/html/docs/glossary.html >> about
them. This document will get you up and running within 10 minutes (that
excludes building Parrot). Once you begin, it's a matter of getting your hands
dirty and get experienced using the tools. Feel free to ask questions in the
#parrot channel on irc.parrot.org .

=head1 GETTING STARTED

Expand Down

0 comments on commit 0a4ca49

Please sign in to comment.