develooper Front page | perl.perl5.porters | Postings from December 2007

Re: optimising opcodes

Thread Previous | Thread Next
From:
demerphq
Date:
December 25, 2007 10:38
Subject:
Re: optimising opcodes
Message ID:
9b18b3110712251038w1449011am25ef03f12ad1878d@mail.gmail.com
On 24/12/2007, Nicholas Clark <nick@ccl4.org> wrote:
> I was thinking about something Jim Cromie mailed me privately, and wondered:
> "How many null ops do we have, and how many cache misses do they cause?"
> For example:
>
> $ perl -MO=Concise -e 'print foreach @ARGV'
> g  <@> leave[1 ref] vKP/REFC ->(end)
> 1     <0> enter ->2
> 2     <;> nextstate(main 1 -e:1) v ->3
> 3     <;> nextstate(main 1 -e:1) v ->4
> f     <2> leaveloop vK/2 ->g
> 8        <{> enteriter(next->c last->f redo->9) lKS ->d
> -           <0> ex-pushmark s ->4
> -           <1> ex-list lKM ->7
> 4              <0> pushmark sM ->5
> 6              <1> rv2av[t1] sKRM/1 ->7
> 5                 <$> gv(*ARGV) s ->6
> 7           <$> gv(*_) s ->8
> -        <1> null vK/1 ->f
> e           <|> and(other->9) vK/1 ->f
> d              <0> iter s ->e
> -              <@> lineseq vK ->-
> b                 <@> print vK ->c
> 9                    <0> pushmark s ->a
> -                    <1> ex-rv2sv sK/1 ->b
> a                       <$> gvsv(*_) s ->b
> c                 <0> unstack v ->d
>
> lots of ex-ops. Pining for the fjords. Taking up space.
>
> So I wondered:
>
> 0: How hard would it be to write some code to take an optree, and copy out all
>   the live ops into a new optree, skipping any nulled out ops?
> 1: Would that break the runtime?
> 2: How much would it break B::Deparse?
> 3: If you configured perl to use a slab allocator, and happened to do two
>   parses (first to determine the total size of ops, second to copy them in)
>   and thereby allocated a slab of the exact size, would that help more?

Based on the experience of the regex engine id say that you dont want
to do this. In order to do advanced optimisations you need a parse
tree to manipulate, but if you do a size only pass there isnt enough
information available to determine if an optimisation is possible.

What im hoping to be able to do in the regex engine is "free allocate"
the nodes in the parse tree, then once all optimisations are complete
copy them into a slab.


yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About