# New Ticket Created by  Leopold Toetsch 
# Please include the string:  [perl #17495]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=17495 >


Appended patch is somewhat experimental and needs probably a configure 
test for the availability of nested functions, and I don't know the 
influence on other platforms/compilers (mine is i386-linux/gcc 2.95.2).

Anyway here is what happens:
Computed goto is the fastest dispatcher and the default runmode, if the 
C compiler supports it.
Profiling e.g. life shows, that most time is spent in trace_system_stack:
14.42      1.23     0.46     5575     0.08     0.09  trace_system_stack
                     ^^^^
(Total runtime 3.19 secs)

  Now, trace_system_stack walks a ~1300 entries deeper stack in CGoto 
run mode, because of the jump table in cg_core. Don't ask me about this 
difference to 900 ops, gdb says so.

Attached patch now sets interpreter->lo_var_ptr beyond this jump table, 
reducing the time of trace_system_stack to 0.04s for above case.

The following test shows a +10% speed increase:

With patch:
$ perl6 -k ../../examples/assembly/life.pasm
5000 generations in 30.183968 seconds. 165.650851 generations/sec
A total of 578912 bytes were allocated
A total of 42743 DOD runs were made
A total of 33 collection runs were made
Copying a total of 535056 bytes
There are 24 active Buffer structs
There are 1024 total Buffer structs
[lt@thu8:~/src/parrot-leo/languages/perl6]

Without patch:

$ perl6 -k ../../examples/assembly/life.pasm
5000 generations in 34.604442 seconds. 144.490121 generations/sec
A total of 578912 bytes were allocated
A total of 42924 DOD runs were made
A total of 33 collection runs were made
Copying a total of 535056 bytes
There are 25 active Buffer structs
There are 1024 total Buffer structs

leo


-- attachment  1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/38261/31102/23f109/cgoto.patch

--- parrot/ops2cgc.pl   Thu Jul 11 10:25:47 2002
+++ parrot-leo/ops2cgc.pl       Sun Sep 22 18:42:28 2002
@@ -158,6 +158,14 @@
 print SOURCE <<END_C;
   NULL
 };
+/* #ifdef HAVE_NESTED_FUNC */
+    static void _check(void);
+    static void _check(void) {
+       int lo_var_ptr;
+       interpreter->lo_var_ptr = (void*)&lo_var_ptr;
+    }
+    _check();
+/* #endif */
 
 goto *ops_addr[*cur_opcode];
 

Reply via email to