[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

oplines - make perl runtime 8% faster and smaller



I had this crazy idea for a while and tested it a bit in theory.
Because there are so many nextstate cops just to record line information
for errors and warnings, and not so many other nexstate cops to record state
(as described in the source)

So the idea is:
Move the cop_line struct entry from COP to BASEOP, and reduce the need
for almost all line-only nextstate ops (99%), which will be an overall win in
memory and speed for typical undense code, say for maybe less than 4 ops
per line.

This will also fix the esoteric tickets for wrong warning line-numbers in
tight loops such while, for and formerly elsif, where we initially didn't
want to pollute the optree with nextstate ops.

A cop has 5 ptrs more than a BASEOP, so the memory win will be like
following:
  with 4 ops/line avg.
  90% nextstate COP win per lines

=> on 32bit: 4*4=16 byte per line. for 10k src => 200-160k=40k memory win.
   + 4k runtime win (need less nextstate cops)
   on 64bit you try.

The unknown factors:
  a) typical # of ops per line
  b) nextstate win:
    * typical # of nextstate cops.
      minus # of really needed nextstate cops (lexicals, new files, hints, ...)

Typical results on the core:
  http://pasta.test-smoke.org/52

./oplines.pl *.pl *.pm
files:       245
lines:       62725
ops:         59263
ops/line:    0.94
cops:        11.23%  (lex+filecops=494 / nextstates=5549)
memory win:  652628 byte  (889680 - 237052)
runtime win: 5055 ops 8.53%  (5549 - 494)

./oplines.pl $(find lib ext -name \*.pm)
files:       12051
lines:       3708262
ops:         6629648
ops/line:    1.79
cops:        39.15%  (lex+filecops=15334 / nextstates=600266)
memory win:  76429440 byte  (102948032 - 26518592)
runtime win: 584932 ops 8.82%  (600266 - 15334)

I also started on that patch, but I'm quite busy with real work and
only have my tiny laptop
so it might need two or three more days to make perl 8% faster and
smaller on pure simple
ops.
And everything without JIT'ing.
-- 
Reini Urban
http://phpwiki.org/ http://murbreak.at/


Follow-Ups from:
Dave Mitchell <davem@iabyn.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]