Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Trading compile time for faster runtime?

by melez (Sexton)
on Apr 20, 2022 at 17:22 UTC ( [id://11143137]=note: print w/replies, xml ) Need Help??


in reply to Re: Trading compile time for faster runtime?
in thread Trading compile time for faster runtime?

I'm not talking about compiling perl into machine code. I'm talking about spotting some common patterns and replacing them with optimized versions that do the same thing. Still with perl OPs.

Perl already does this. Subroutines with empty prototype and constant return value are inlined (not actually called on the runtime). If statements that have constant false condition will not be included in the internal compiled structure at all. Currently existing optimizations are pretty straightforward, I think mostly constant folding, to avoid long startup time of a program. What I mean is to have more of those with less focus on fast compile time, as an executable flag for easy on/off. Yes, potential gains may not be worth it or there might be some technical reasons why this isn't viable.

Replies are listed 'Best First'.
Re^3: Trading compile time for faster runtime?
by LanX (Saint) on Apr 20, 2022 at 19:51 UTC
    could you show an example, please?

    perl -MO=Concise FILE will show you the OP tree.

    NB: the tree doesn't mean the order of execution, you have to read the line numbers.

    C:\>perl.exe -MO=Concise -e"map {$_++} 1..3" d <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 7 <|> mapwhile(other->8)[t5] vK ->d 6 <@> mapstart K ->7 3 <0> pushmark s ->4 - <1> null lK/1 ->4 - <1> null lK/1 ->7 c <@> leave lKP ->7 8 <0> enter l ->9 9 <;> nextstate(main 2 -e:1) v:{ ->a b <1> postinc[t2] sK/1 ->c - <1> ex-rv2sv sKRM/1 ->b a <#> gvsv[*_] s ->b 5 <1> rv2av lKPM/1 ->6 4 <$> const[AV ] s ->5 -e syntax OK

    more options in B::Concise

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Can't, as I said - I have close to zero experience with XS. My question was hypothetical, but others have pointed out that it was attempted already, both in the core as well as on CPAN.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11143137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 01:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found