[svn:parrot] r44997 - in trunk: docs/dev include/parrot lib/Parrot/Ops2c src/runcore
cotto at svn.parrot.org
cotto at svn.parrot.org
Thu Mar 18 07:05:14 UTC 2010
Author: cotto
Date: Thu Mar 18 07:05:09 2010
New Revision: 44997
URL: https://trac.parrot.org/parrot/changeset/44997
Log:
[profiling] enable generation of profiles that will always be identical given the same PIR
Modified:
trunk/docs/dev/profiling.pod
trunk/include/parrot/runcore_profiling.h
trunk/lib/Parrot/Ops2c/Utils.pm
trunk/src/runcore/profiling.c
Modified: trunk/docs/dev/profiling.pod
==============================================================================
--- trunk/docs/dev/profiling.pod Thu Mar 18 07:01:16 2010 (r44996)
+++ trunk/docs/dev/profiling.pod Thu Mar 18 07:05:09 2010 (r44997)
@@ -55,6 +55,19 @@
profiling runcore to run more slowly. By default, they are disabled. Set this
value to enable them.
+=item C<PARROT_PROFILING_CANONICAL_OUPUT>
+
+When this is set, the profiling runcore will record all addresses as a single
+constant value and all times as 1. This options is useful primarily for
+testing, where it's helpful to have a way to ensure that a given chunk of code
+will always produce exactly the same profile. If you want this feature
+enabled, you also probably want to pass a fixed hash seed to Parrot via
+C<--hash-seed 1324> to avoid any non-deterministic behavior that hash seed
+randomization may cause.
+
+This variable is not useful apart from testing the profiling runcore and will
+most certainly not help you find hotspots in your code.
+
=back
=cut
Modified: trunk/include/parrot/runcore_profiling.h
==============================================================================
--- trunk/include/parrot/runcore_profiling.h Thu Mar 18 07:01:16 2010 (r44996)
+++ trunk/include/parrot/runcore_profiling.h Thu Mar 18 07:05:09 2010 (r44997)
@@ -27,8 +27,8 @@
PROFILING_EXIT_CHECK_FLAG = 1 << 0,
PROFILING_FIRST_LOOP_FLAG = 1 << 1,
PROFILING_HAVE_PRINTED_CLI_FLAG = 1 << 2,
- PROFILING_REPORT_ANNOTATIONS_FLAG = 1 << 3
-
+ PROFILING_REPORT_ANNOTATIONS_FLAG = 1 << 3,
+ PROFILING_CANONICAL_OUTPUT_FLAG = 1 << 4
} Parrot_profiling_flags;
typedef enum Parrot_profiling_line {
@@ -129,6 +129,13 @@
#define Profiling_report_annotations_CLEAR(o) \
Profiling_flag_CLEAR(o, PROFILING_REPORT_ANNOTATIONS_FLAG)
+#define Profiling_canonical_output_TEST(o) \
+ Profiling_flag_TEST(o, PROFILING_CANONICAL_OUTPUT_FLAG)
+#define Profiling_canonical_output_SET(o) \
+ Profiling_flag_SET(o, PROFILING_CANONICAL_OUTPUT_FLAG)
+#define Profiling_canonical_output_CLEAR(o) \
+ Profiling_flag_CLEAR(o, PROFILING_CANONICAL_OUTPUT_FLAG)
+
/* HEADERIZER BEGIN: src/runcore/profiling.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
Modified: trunk/lib/Parrot/Ops2c/Utils.pm
==============================================================================
--- trunk/lib/Parrot/Ops2c/Utils.pm Thu Mar 18 07:01:16 2010 (r44996)
+++ trunk/lib/Parrot/Ops2c/Utils.pm Thu Mar 18 07:05:09 2010 (r44997)
@@ -200,7 +200,7 @@
my ( $op_info, $op_func, $getop );
$op_info = $op_func = 'NULL';
- $getop = '( int (*)(PARROT_INTERP, const char *, int) )NULL';
+ $getop = 'NULL';
if ($self->{suffix} eq '') {
$op_func = $self->{bs} . "op_func_table";
Modified: trunk/src/runcore/profiling.c
==============================================================================
--- trunk/src/runcore/profiling.c Thu Mar 18 07:01:16 2010 (r44996)
+++ trunk/src/runcore/profiling.c Thu Mar 18 07:05:09 2010 (r44997)
@@ -148,7 +148,7 @@
{
ASSERT_ARGS(init_profiling_core)
- char *profile_filename, *output_cstr, *filename_cstr, *annotations_cstr;
+ char *profile_filename, *output_cstr, *filename_cstr;
/* initialize the runcore struct */
runcore->runops = (Parrot_runcore_runops_fn_t) runops_profiling_core;
@@ -227,12 +227,14 @@
}
/* figure out if annotations are wanted */
- annotations_cstr = Parrot_getenv(interp, CONST_STRING(interp, "PARROT_PROFILING_ANNOTATIONS"));
-
- if (annotations_cstr) {
+ if (Parrot_getenv(interp, CONST_STRING(interp, "PARROT_PROFILING_ANNOTATIONS"))) {
Profiling_report_annotations_SET(runcore);
}
+ if (Parrot_getenv(interp, CONST_STRING(interp, "PARROT_PROFILING_CANONICAL_OUTPUT"))) {
+ Profiling_canonical_output_SET(runcore);
+ }
+
/* put profile_filename in the gc root set so it won't get collected */
Parrot_pmc_gc_register(interp, (PMC *) runcore->profile_filename);
@@ -395,8 +397,16 @@
pprof_data[PPROF_DATA_NAMESPACE] = (PPROF_DATA) full_ns_cstr;
pprof_data[PPROF_DATA_FILENAME] = (PPROF_DATA) filename_cstr;
- pprof_data[PPROF_DATA_SUB_ADDR] = (PPROF_DATA) preop_ctx->current_sub;
- pprof_data[PPROF_DATA_CTX_ADDR] = (PPROF_DATA) preop_ctx;
+
+ if (Profiling_canonical_output_TEST(runcore)) {
+ pprof_data[PPROF_DATA_SUB_ADDR] = (PPROF_DATA) 0x3;
+ pprof_data[PPROF_DATA_CTX_ADDR] = (PPROF_DATA) 0x3;
+ }
+ else {
+ pprof_data[PPROF_DATA_SUB_ADDR] = (PPROF_DATA) preop_ctx->current_sub;
+ pprof_data[PPROF_DATA_CTX_ADDR] = (PPROF_DATA) preop_ctx;
+ }
+
runcore->output_fn(runcore, pprof_data, PPROF_LINE_CONTEXT_SWITCH);
Parrot_str_free_cstring(full_ns_cstr);
@@ -443,8 +453,13 @@
}
}
+ if (Profiling_canonical_output_TEST(runcore)) {
+ pprof_data[PPROF_DATA_TIME] = 1;
+ }
+ else {
+ pprof_data[PPROF_DATA_TIME] = op_time;
+ }
pprof_data[PPROF_DATA_LINE] = preop_line;
- pprof_data[PPROF_DATA_TIME] = op_time;
pprof_data[PPROF_DATA_OPNAME] = (PPROF_DATA)(interp->op_info_table)[*preop_pc].name;
runcore->output_fn(runcore, pprof_data, PPROF_LINE_OP);
}
More information about the parrot-commits
mailing list