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

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

by Will_the_Chill (Pilgrim)
on Aug 27, 2012 at 21:18 UTC ( #990064=note: print w/ replies, xml ) Need Help??


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

I've got the significant edge-case Perl code base, and I am the one "in great pain", thus my personal interest in running down this particular dream.


Comment on Re^3: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
Re^4: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
by bulk88 (Priest) on Aug 28, 2012 at 11:08 UTC
    What exactly is your edge case? Maybe there is a better way to solve your problem, like fixing a particular poorly performing opcode in perl, or a couple XS functions, than taking the most difficult choice.

    And what are the resources you can supply for your idea (time, $, PhDs, patents, etc)?

    If you are going to do it yourself, just do it. You dont need anyones permission. Perl is open source. Once you have a working prototype with before and after benchmarks, you will start to attract volunteers and corporate users and the rest is history. Not to mention Perl does have hooks for optimizers and "custom" opcodes. You can always JIT an optimizable Perl sub into what perl thinks is XSUB, just change the right fields in the CV struct.

    If I were you, I would hire a couple programmers with knowledge in compiler design/HLA/interpreter VMs, select a couple Perl subs no more than 1 screenful each off of CPAN, the selection doesn't need to be random, there can be a bias, but it must have enough ";"s, have the programmers try and see if they can compile the Perl subs from A. Human Perl or, B. Bytecode Perl to one or more popular bytecode interpreters, Web Grade Javascript, LLVM, .NET CIL, Java bytecode, really anything. Measure the benchmarks of the before and after. If its faster, great, publish it, you don't need anyones permission. If its slower, try a different VM target. Your real work is how to convert Perl to something closer to the hardware. Anyone can writing Perl interpreter that targets any other programing language that is Turing complete but speed would be much worse than today. I dont know what perlito's current speed is against perl. Someone should research that.

    Maybe the question you really want to ask is, not whether Perl 5 can use LLVM, but what is the future of LLVM by itself?

    I will guess the future is excellent, it is OSX's primary compiler. Apple seems to be the primary sponsor and financier of LLVM. It is not going away anytime soon.

    update: there are other people who have ideas on JIT to machine code in perl http://www.nntp.perl.org/group/perl.xs/2012/07/msg2709.html
      bulk88,

      Sorry for the delayed reply, the thread is getting long and twisty!

      Imagine my edge cases are something like an entire operating system or some high-performance parallel code or an attempt at strong AI. There are many kinds of code that would benefit greatly from general-purpose runtime optimization. Yes, I have such code.

      I can supply my own time, as well as the time of my modest Perl team. I can supply coordination efforts and put together funding for qualified coders. I can even code. I'm not sure what patents you think we would need?

      I'm not looking for permission to do this, I'm looking for a WAY to do this. So far my options all seem to require some amount of speculation and collaboration with the most talented coders around. Fun!

      Yes, the general idea is to put together funding to hire a few programmers and have them target various backends such as LLVM. I think LLVM may have a very bright future.

      I looked at the stuff you linked from David Mertens about the Tiny C compiler, but I'm not sure how it relates to what we're doing?

      Thanks,
      ~ Will
        Imagine my edge cases are something like an entire operating system or some high-performance parallel code or an attempt at strong AI. There are many kinds of code that would benefit greatly from general-purpose runtime optimization. Yes, I have such code.
        Auto-parallelization/auto-threading for cpu bound algorithms, thats a worthy idea and aslong as there are no evals or the lexicals never leave the sub, auto-parallization should be possible automatically. Since Perl optrees can almost always be converted back to their original source code (except for constant folding and dead code elimination from "const" value perl subs), try to convert a Perl sub that that takes 1 @_ SV, copies it to a lexical (loosing magic and tied I believe in the process) SV, does a series of math operations against it using const numbers, and returns the new value in scalar context (thats 1 line of code). The CV is converted from being Perl bytecode to being an XSUB in machine code, and the C function is a call to 1 C function that makes a call to the LLVM VM to run precompiled to LLVM Bytecode LLVM Bytecode, or to the JIT machine code produced by LLVM. In Perl I guess how you try to optimize a sub would be
        LLVM::compile(\&somePurePerlSub);
        I presume the BioPerl/Biological Science sector folks, might throw you some grants if your successful.
        I can supply my own time, as well as the time of my modest Perl team. I can supply coordination efforts and put together funding for qualified coders. I can even code. I'm not sure what patents you think we would need?
        I included the patents just as an example. If you are one guy with a dream, and no resources, you have to do it yourself or convince someone to give you $ so you can do your dream as a day job.

        I looked at the stuff you linked from David Mertens about the Tiny C compiler, but I'm not sure how it relates to what we're doing?

        Thanks,
        ~ Will

        It really doesn't, it just shows that others have had realistic ideas of plugging foreign code from "compilers" at runtime into perl.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-07-24 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls