Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of nicholas (3034)

Wednesday June 28, 2006
12:04 PM

make perl faster?

[ #30082 ]

Curiously in the past 24 hours two different entities have effectively asked the same question - "given development funding, can the Perl core be made faster?"

Having spent a couple of years trying to benchmark, profile and accelerate the core, generally with no measurable impact, I'm coming to the general conclusion "no". Of course, there are specifics - there are still some algorithmic wins to be made in the regexp engine, and Yves' recent work on these is very welcome. In turn, there are improvements that can be made to the regexp engine's optimiser (the code that attempts to avoid even calling into the engine itself). But apart from that, my considered opinion after banging my head against the problem for so long is

  1. Ouch!
  2. There are no significant wins left to be found

I reserve the right to be proved wrong. Only working proofs will be accepted. :-)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I can describe a working method for making the perl core faster, but it involves upgrading the processor you are using. And all of us will probably be doing it at least once in the next 3-7 years or so.

    --
    J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
  • What about Parrot? Isn't that supposed to make things faster, in part by switching from a stack model to a register model (and thus making optimisation easier), and also by making things easier to optimise at "compile" time?

    Or is Parrot not the great-white-hope we think it is?
    • The trick is refactoring (or reimplementing) Perl 5 so that it runs on Parrot. It ought to make things faster though.

      • Right. That's what I figured. I seem to distantly remember a project to do just that :-)
        • I seem to distantly remember a project to do just that :-)

          I think you mean PONIE [poniecode.org]. Shame that none of the links on that page seem to go anywhere useful.

          Did we ever get an official announcement on what was happening with PONIE? There was a lot of action three years ago, but it all seems to have died out now?

          • I believe Ponie is dead. Nicholas stepped down as pumpking some time back, and a call went out for a replacement, and exactly zero candidates came forward.

            Arthur Bergman might still be working on Ponie, I'm not sure, but in any event I haven't heard any noises of activity coming out of the lab (stable?) for some time. Certainly nothing so far as p5p is concerned, nor any other of the various perl fora and lists I pay attention to.

            But that's ok, we all know Perl is a volunteer-based operation.
  • In case my parrot comment didn't stab you enough :-)

    A way of properly doing objects might actually speed things up a lot. If you could have a class with defined attributes so that when you access those attributes you don't have to go through a hash (or array even) you can get some decent performance improvements for object heavy systems (as fields.pm hints at).

    Admittedly this doesn't affect boring benchmark applications, but it does help people whose day job it is building large scale apps with perl, and it
    • This sounds like a lot of work. If someone want to volunteer to write such a thing, then great, patches welcome - although they should be warned that there can be no guarantee in advance that code will be accepted.

      But I don't think that any of the current maintainers have a sufficient itch to scratch personally, so I cannot see such a project happening "by itself".

      • Sure. But you did say "given development funding". So I took that as to mean "given infinite funding and infinite available monkeys". Hey I can dream can't I ;-)
        • A right. I didn't pick up on this as an approach to solving the "make perl faster". I was seeing the requestor's desire more to be to make their existing perl code faster (at least, without substantial re-writes). And this seems more like a way to make new code faster.

          In turn, such an approach might have the same "speedup" as pseudo-hashes. Offhand I don't know the URL to the analysis, but someone [Schwern, IIRC] demonstrated that the real 15% speedup that pseudo-hashes provided for use fields over regula

          • Thinking of Perl 6 being ready in 3 years is dreaming. Sorry, but someone has to say it.

            Classes need not be accessed through the hash API. I think of a class (or object) as another xV type, rather than another extension on SVs. But I know zip about the perl core - I'm purely speculating based on the little work I have done in XS.

            I remember Schwern's analysis, but I also remember it being rather flawed because there's lots in later perls that slow it down (most notably unicode) that weren't taken into consid
            • I am sorry, but v6.pm [cpan.org] works today; the underlying support modules (Moose, Pugs::Compiler::Rule, ModulE::Compile) are useful in production; Perl 6 is just another CPAN module, and we are working to make it useful for production in this Christmas.

              But you can use Moose or any other support modules without the v6.pm syntax sugar; if so, then it's ready even sooner.

              • Also, by "CPAN module" I mean "pure perl 5 CPAN module with some XS dependencies like PadWalker", so you do not need to install GHC or Parrot or any other runtime to make Perl 6 work. which makes it far easier to deploy, too...
              • We were talking about different things here (perl 6 being a fully finished and working perl 6 on its own interpreter). But saying v6.pm is working today is a long way off saying it's a finished perl 6. The perl 6 schedules have been way off from the start and I think my expectation of us being ready to transition people to perl 6 in 3 years is probably about right given what I know of the current development stage (unless there will be a Blue Peter "and here's one I made earlier" phase ;-)).

                In no way do I m
                • Frankly I think the Perl 6 on its own interpreter idea doesn't work at all.

                  It's true that Perl 6 will run on multiple interpreters (including Parrot, JavaScript and more), but it's the perl5 interpreter that will get us to an incrementally-deployed production soonest.

                  That is, the transition to Perl 6 will be no different to, say, the transition to DateTime.pm; modules start using it, or part of it, when it makes sense, but it doesn't need to be an all-of-nothing process. :-)

  • why fucking bother? Machines are getting faster and if the legacy code isn't working fast enough, instead of wasting time/money/angst on p5 perhaps migrating to something known for its speed would be a better use of resources. Tilting at windmills is only for the true romantics. As I recall, someone asked the same question a while back and came to the same 'no' conclusion. I also seem to remember Alan Burlison having a few cutting, yet fitting, remarks about squeezing a few more drops of speed out of the
    • Machines are getting faster...

      Only the new ones.

      • Also for large systems there comes the tipping point where developer time actually becomes cheaper than the costs of machines, maintenance and rack space. It's these sort of entities who were asking the question.

        • As someone who works in a joint with a Sun 25k, I realise that there are slower, cheaper options :) However, at the point where you have the cost of a new machine exceeding the cost of labour, does the speed of the archaic code matter that much and, if it does, doesn't it make more sense to just rewrite it using something else...like C?
          • It was firms with over 50,000 lines of perl code that were thinking about it, one of which I know is running code across several hundred servers. I doubt that re-writing the whole thing in C (or anything) is easy, as I'm guessing that the cost of validating that the behaviour is the same is prohibitive, but re-writing parts might well be, if those parts can be identified. But I think that both were thinking that it still might be easier to concentrate resources on the core, as that could speed up all code,

            • Well, with something like that you have to consider so many other possible bottlenecks, especially since much of the clustering software, if that's what they're using, do exact a speed toll. I'd call them outright awful, but a few of them do actually manage to work on occasion.

              And, given the pain and suffering involved with changing most anything in the perl core, *ahem*, I'd guess that rewriting large parts or the whole thing would be faster and far less hassle with a greater performance gain. Anyone w

  • I know this comment is late, but I was wondering if it would be feasible to inline function calls to avoid the function call overhead? I remember chromatic mentioning that he looked into this and saw that the pads were going to slow it down regardless (I could be misremembering) and I suspect that the difficulty in distinguishing between methods and subroutines would make this idea pretty much dead, but if it was feasible, would this speed up Perl?

    • Well, you have to assume that the function isn't going to get dynamically redefined. (or even memoized [cpan.org]). So inlining would be more like macros than true functions. I think someone was mentioning this on p5p at some point, but I've no idea how evolved (or involved) the implementation would be.