A lot of good tiny ideas

brian d foy was here in Houston for two days and I got a lot of good tiny ideas:

1. implement last out of grep/map (disabled because broken with 5.6)

2 days. step out 2 scopes in dopoptoloop:
grep, grep_item, block

$ p -MO=Concise,-exec -e'grep{last if $_ == 2} 1..3'
1 <0> enter
2 <;> nextstate(main 2 -e:1) v:{
3 <0> pushmark s
4 <$> const(AV ) s
5 <1> rv2av lKPM/1
6 <@> grepstart K*
7 <|> grepwhile(other->8)[t3] vK
8 <0> enter s
9 <;> nextstate(main 1 -e:1) v:{
a <$> gvsv(*_) s
b <$> const(IV 7) s
c <2> eq sK/2
d <|> and(other->e) sK/1
e <0> last s*
f <@> leave sKP
goto 7
g <@> leave[1 ref] vKP/REFC

$ p -Dl -e'grep{last if $_ == 2} 1..3'
(-e:0) Entering new RUNOPS level
(-e:0) ENTER "block" scope 2 (savestack=0) at pp_ctl.c:2126
(-e:0) CX 0 PUSH BLOCK (scope 2,2) at pp_ctl.c:2129
(-e:1) ENTER "grep" scope 3 (savestack=2) at pp_ctl.c:1065
loop:
(-e:1) ENTER "grep_item" scope 4 (savestack=7) at pp_ctl.c:1072
(-e:1) ENTER "block" scope 5 (savestack=10) at pp_ctl.c:2126
(-e:1) CX 1 PUSH BLOCK (scope 5,5) at pp_ctl.c:2129
last => grep scope 3
(-e:1) CX 1 POP BLOCK (scope 5,5) at pp_ctl.c:2147
(-e:1) LEAVE "block" scope 5 (savestack=12) at pp_ctl.c:2155
(-e:1) savestack: releasing items 12 -> 10
(-e:1) LEAVE "grep_item" scope 4 (savestack=10) at pp_hot.c:2430
(-e:1) savestack: releasing items 10 -> 7


2. tail-recursion (as outlined by Nick Clark on p5p)
2 days in C (more as XS module)

3. perlcc perldoc and measure speed => found nasty AMT bug, c-magic
fix bugs first

4. precompile an index for the perl pods, find also ops
2 weeks min.

5. fix blead for Solaris CC
1 day. first fix worked on solaris and linux but not on darwin/cygwin

6. stabilize Benchmark
fail if load > 0.3, check some iterations against null op runs, measure quality (repeatability, reject outliers, measure only stable iterations), graph. finally implement getloadavg() on windows

7. implement a taint bit on hek's
The highest bit in len is free, only -2 is special.
Converting to from hash keys is a nasty trick to bypass string tainting, besides regexp
catching.

8. finish B::Stats - op stats at load- and run-time. People requested it.
https://gist.github.com/483401

9. implement a Benchmark::Core which has a fair and typical op coverage, with CORE modules down to 5.6.2 only. The testsuite would be best but cannot be measured accross versions because the number and content of tests changed.

Smoker times will lead to nothing comparable, http://speed.perlformance.net/timeline/ is far too big and coarse and only back to 5.12.

My take on this was http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2010-09/msg00403.html and see http://search.cpan.org/dist/Dumbbench/
with sub f{my($n)=@_;$n==8 and bless{1..4}and$a=~s/$/../;$n<2 and
return$n;f($n-1)+f($n-2)}f(33)

tak with 33 recursions and some basic perl features which leads to about 10 secs runtime. It should be improved as it merely measures function calls, not array or hash access, nor regex.


1 Comment

tail-recursion, seems to have been on the CPAN for two years anyway...

http://search.cpan.org/perldoc?Sub::Call::Tail

Leave a comment

About Reini Urban

user-pic Working at cPanel on B::C (the perl-compiler), p2, types, parrot, B::Generate, cygwin perl and more guts (LLVM, jit, optimizations).