Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Yes, but Dave's point is that that's not the slow part of Perl 5. You either generate LLVM code specific to the semantic knowledge of Perl 5 programs or you precompile any Perl 5 program you want to optimize to bitcode and let LLVM do whole program analysis. In the latter case, you may be able to get more than 20% improvements if enough of your code stays in analyzable chunks and you can perform optimizations like dead code elimination and hoistings. In the former case, you have to tell LLVM about the semantics of the language because it can't infer them from a big wad of C code.

LLVM may be able to optimize the source code of the Perl 5 VM and that may be worthwhile, but that doesn't necessarily provide a measurable improvement to programs written in Perl 5.

(Let me belabor this point with what should be a really obvious example.)

Suppose I wrote a program that reads a multi-gigabyte file line by line to pick out a handful of records. No matter how much I microoptimize my code to get rid of dispatch overhead, I'm only going to get real speed benefits one of two ways: if I fix that algorithmic problem by hand, or if some very clever analysis of the code by something which understands the semantics of the code can rewrite it for me.

Unfortunately, LLVM doesn't understand the semantics of the Perl 5 language. That's why you either have to get the entire program into bitcode (so that it can infer what's going on at a level it does understand) or build up some sort of LLVM-aware VM that can map the semantics of the language to LLVM's intermediate form such that intelligent JITting is possible.

Unless you do one of those two things, your theoretical maximum improvements are in the "Hey, that's a nice improvement, but it doesn't transform things" arena. Maybe in certain cases people are willing to spend a couple of hours on a powerful machine to compile an important program to bitcode and then to native code, but I'm not sure that's the end goal here.

In reply to Re^7: Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges by chromatic
in thread Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges by Will_the_Chill

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (5)
    As of 2014-10-02 01:01 GMT
    Find Nodes?
      Voting Booth?

      What is your favourite meta-syntactic variable name?

      Results (41 votes), past polls