[svn:parrot] r41941 - in trunk: include/parrot src/runcore
cotto at svn.parrot.org
cotto at svn.parrot.org
Mon Oct 19 15:16:10 UTC 2009
Author: cotto
Date: Mon Oct 19 15:16:09 2009
New Revision: 41941
URL: https://trac.parrot.org/parrot/changeset/41941
Log:
[profiling] add a pc->line number cache to the profiling runcore
This speeds up oofib.pir profiling by about 13.9% and drastically reduces the
time spent in Parrot_Sub_get_line_from_pc, reducing it from ~38% to ~0%.
(parrot_hash_get is at about 2.74%.) This will cause a slowdown for programs
without many loops, but such programs are not likely to be profiled in the
first place.
Modified:
trunk/include/parrot/runcore_profiling.h
trunk/src/runcore/profiling.c
Modified: trunk/include/parrot/runcore_profiling.h
==============================================================================
--- trunk/include/parrot/runcore_profiling.h Mon Oct 19 14:49:46 2009 (r41940)
+++ trunk/include/parrot/runcore_profiling.h Mon Oct 19 15:16:09 2009 (r41941)
@@ -45,6 +45,7 @@
UINTVAL level; /* how many nested runloops */
UINTVAL time_size; /* how big is the following array */
UHUGEINTVAL *time; /* time spent between DO_OP and start/end of a runcore */
+ Hash *line_cache; /* hash for caching pc -> line mapping */
};
Modified: trunk/src/runcore/profiling.c
==============================================================================
--- trunk/src/runcore/profiling.c Mon Oct 19 14:49:46 2009 (r41940)
+++ trunk/src/runcore/profiling.c Mon Oct 19 15:16:09 2009 (r41941)
@@ -147,6 +147,7 @@
runcore->runloop_count = 0;
runcore->level = 0;
runcore->time_size = 32;
+ runcore->line_cache = parrot_new_pointer_hash(interp);
runcore->time = mem_allocate_n_typed(runcore->time_size,
UHUGEINTVAL);
Profiling_first_loop_SET(runcore);
@@ -257,9 +258,13 @@
Parrot_ex_throw_from_c_args(interp, NULL, 1,
"attempt to access code outside of current code segment");
- preop_line = Parrot_Sub_get_line_from_pc(interp,
- Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp)),
- CONTEXT(interp)->current_pc);
+ preop_line = parrot_hash_get(interp, runcore->line_cache, CONTEXT(interp)->current_pc);
+ if (preop_line == NULL) {
+ preop_line = Parrot_Sub_get_line_from_pc(interp,
+ Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp)),
+ CONTEXT(interp)->current_pc);
+ parrot_hash_put(interp, runcore->line_cache, CONTEXT(interp)->current_pc, preop_line);
+ }
CONTEXT(interp)->current_pc = pc;
preop_sub = CONTEXT(interp)->current_sub;
@@ -367,6 +372,7 @@
"output from this file.\n", filename_cstr);
Parrot_str_free_cstring(filename_cstr);
+ parrot_hash_destroy(interp, runcore->line_cache);
fclose(runcore->profile_fd);
mem_sys_free(runcore->time);
More information about the parrot-commits
mailing list