RPerl – optimizing compiler for Perl 5
github.com
github.com
"A: Early tests show the potential to run RPerl apps about 7x faster than normal Perl 5 when using Perl data structures, and up to 170x-350x faster when using C++ data structures. This does not include any fancy optimization techniques which could add even more speed in the future."
On the damper side, I'd caution against too much "fast" (usually in the "as C" context) excitement. There have now been many different efforts to speed up the 1990s-dynamic-scripting languages now, most notably Javascript but they all have fairly similar issues when running at speed, and as near as I can tell, on general code all of them have plateaued at roughly 6-10x slower than C. "Just compile it as C++" has been done.
On the "get excited" side, it's about time somebody may have some success at getting Perl to this performance level. Perl's really been left out in the cold by its fellow 1990s-dynamic-scripting brethren lately, between PyPy, all the JS efforts, all the various PHP engines and Hack.... It and Ruby have been left out of all the action, and there's a ton of code out there that could use the improvement.
That is some magic right there. Similar kinds of craziness (like the Inline module itself) is some of what gives Perl so much charm :)
* The definition of "low-magic" (v. - presumably - "high-magic") seems to be unclear, even with the rules specified in the "Low-Magic Perl Commandments". It's also unclear if that's a hard restriction on what Perl code RPerl is able to understand or if it's a strong recommendation for performance/safety/security/cleanliness/sanity/etc. Are there any code samples floating around re: what a sample RPerl-friendly Perl program would look like?
* The FAQ states that RPerl is released under the same terms as Perl 5.22.0, which is subject to the GPL and the Artistic License. However, the FAQ states that selling binaries without accompanying source code is forbidden, yet doing so seems to be allowed by Section 4 of the Artistic License (particularly clauses 'a' and 'c'). Is this intentional? Did the RPerl folks mean for RPerl to be GPL-only? Am I just misinterpreting the text of the Artistic License?
* The data must be all typed,
* there needs to exist a C++ mapping for this type,
* and there need to exist a C++ mapping for these typed ops.
Since rperl does this transparently it's a bit hard to tell which parts get optimized and which not. I hope we can create better tools or docs to see it.re LICENSE: This additional selling clause is a violation of the ARTISTIC license, yes. But you can just fork rperl, delete this selling clause, and you should be fine, since rperl itself is under the dual perl license.
I only found it because I do a HN search for Perl stories and comments ordered by date every few days, to see if anything interesting was mentioned. But, you have an account now, so next time this drops on HN, you should jump on ASAP. People here love getting specific in-depth answers for their sometimes very involved questions. ;)
The "R" in the name is unfortunate as it might confuse a population that thinks of "R" as a language.
The author is a bit confused what a optimizing compiler is. You have to forgive him. rperl is a restricted perl which maps typed data via Inline::CPP to C++, and if all ops and data in a function are properly typed and not-dynamic ("no magic"), then the function can be compiled to C++ and executed there. Thus the 200x performance win for certain static and typed parts.
And there exist "optimizing compilers" for perl 5, rperl is more a transparent perl - C++ mapping where gcc does the optimizations.
Thou Shalt Not: 45. Use Regular Expressions, Smart Match, q Quoting Mechanisms, Unicode/UTF-8, Or String Interpolation
And the performance of Perl's regular expressions is rarely something that slows down actual code. Using it in the first place (instead of more specific parsing) might be an item, though...
In my perl variant I'm planning to improve the inefficient and overly simple and troublesome Spencer two-pass compiler with backtracking support to use the faster Thompson NFA without backtracking (RE2), and/or switch to pcrejit when no pcre-incompatible ops are used, like unicode character classes. The first pass which calculates the space can be easily used for that.
But a better regex compiler should get away with one-pass and extend the ops dynamically.