P6 will pretty much always need to inspect every parameter to a function call at runtime in order to determine which multi-sub to invoke.

Aiui P6 by design, and Rakudo in actuality, pretty much always resolve the dispatch target of a call with multisub candidates at compile-time, not run-time. See my previous comment in this thread for more details.

My overall point is that adding the syntactic convenience of multi-subs to P6 -- which will probably never be able to benefit from such optimisations -- is another nail in its coffin for programming where performance is important.

If you've read the comment I linked above you've hopefully switched to accepting that P6 multisubs in general, and as they have been used in P6 code to date, appear to perform roughly the same, speed-wise, as non multi subs in current Rakudo.

You've hopefully also seen why I think a literal parameter is supposed to be considered a singleton value, which in turn is acceptable as a finite set of values, which in turn enables the multisub resolution to stay compile-time. And why this isn't yet the case with Rakudo.


Even assuming that most multisub dispatches (in P6) are resolved at compile-time (and are thus no slower than non multi sub dispatches in P6), something about sub dispatching and calling in P6 leads to it being -- at least in my tests in this thread -- one or two orders of magnitude slower than perl (5) sub dispatches. Why?

One reason is missing optimizations. While Rakudo has been getting faster most months for years, the classic optimization phases and mechanisms now built in to Rakudo, NQP and MoarVM only landed last year. Folk have to actually use them to add the thousands of significant optimizations that are possible. Jonathan is wisely leaving these for others to pick off at their leisure while he focuses on stuff that realistically only he can do. Can sub dispatch get a whole lot faster? My guess is yes, way faster, but I'll investigate that guess and report back here on what I hear is possible.


Could P6 deliver value for some applications where performance is important? Several P6ers have written video games with Rakudo and I assure you they all think (enough) performance is very important! :) But seriously, I agree that Rakudo doesn't currently look like a strong candidate for writing high performance computing applications. To put it mildly. :)


Some news about incremental improvements:


In reply to Re^11: rough approximation to pattern matching using local (Multi Subs) by raiph
in thread rough approximation to pattern matching using local by gregory-nisbet

Title:
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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.