Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?

by chromatic (Archbishop)
on Aug 29, 2012 at 04:25 UTC ( #990377=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
in thread Perl 5 Optimizing Compiler, Part 4: LLVM Backend?

Perl 5 doesn't run slower than C because it lacks a JIT. Perl 5 runs slower than C because it's designed to be more flexible than C and that flexibility is not free. That flexibility includes but is not limited to:

  • reference counting
  • automatic destruction at scope leave
  • flexible typing and coercion
  • eval
  • dynamic dispatch
  • method dispatch
  • overloading
  • autoloading
  • importing
  • pragmas
  • monkeypatching
  • metaprogramming
  • closures
  • symbolic references
  • exceptions
  • dynamic data structures

Add to that the facts that LLVM was not designed for dynamic languages and that Perl 5 was not designed for static optimizations. Using LLVM from Perl 5 without changing the internals of the Perl 5 VM probably will speed up code that's already written in C but certainly without addressing most of the reasons why Perl 5 code can run slower than C.


Comment on Re^4: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
Re^5: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
by Will_the_Chill (Pilgrim) on Aug 29, 2012 at 04:53 UTC
    chromatic,

    I guess I'm a bit confused. Above you say:
    Perl 5 doesn't run slower than C because it lacks a JIT.
    But here you say:
    Add a tracing JIT. Iterate on that for a few years.
    So which is it? JIT good or JIT bad?

    ...

    Other than that potential logical inconsistency, I am in general agreement with your premises of Perl-runs-slow-because-it-is-dynamic and LLVM-was-not-designed-for-dynamic-languages. However, until a better backend target is determined, it looks like LLVM may be one of our best options.

    If we can clean up some of the Perl internals along the way to Perl5-on-LLVM, then we can either change the backend target to a more-dynamic-than-LLVM platform or just upgrade LLVM to support dynamic language features.

    Thanks,
    ~ Will
      So which is it? JIT good or JIT bad?

      That reads to me like a false dilemma.

      In the rest of the post where I said "Add a tracing JIT", I wrote about the other necessary improvements to take advantage of a tracing JIT.

      If we can clean up some of the Perl internals along the way to Perl5-on-LLVM, then we can either change the backend target to a more-dynamic-than-LLVM platform or just upgrade LLVM to support dynamic language features.

      The word "just" in there reads to me like an oversimplification.

      Have you read the Dragon book? Taken a compilers class? Written your own Scheme or Forth? Written an interpreter? I appreciate your enthusiasm, but I think you're committing to a schedule and a lot of engineering decisions before you've done enough research to know what goes into a project like this.

        chromatic,

        I admit, I was setting up a potentially-false JIT dichotomy to try and understand your arguments better.

        Immediately after posting, I figured my use of the term "just" in "just upgrade LLVM" was in poor form - I should have omitted the "just", I agree that it is an oversimplification.

        ...

        Yes, I own and have read the Dragon book.
        Yes, I've taken a compilers class during the process of getting a degree in computer science.
        Yes, I have written my own functional and procedural languages, complete with BNF grammars, etc.
        Yes, I've written more than one interpreter.

        ...

        I am glad you appreciate my enthusiasm. I appreciate your frank input.

        The schedule I'm committing to is to have something (anything!) to demo by YAPC::NA 2013.

        I have not committed to any engineering decisions, as I am still in the process of research and due diligence. I've spent the last decade working on language theory and design, so I'm not a total newbie here. I'm just not (yet) a Perl Pope or Pumpking. ;)

        Thanks,
        ~ Will

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-12-25 18:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (161 votes), past polls