next::method and Co huge speedup + super::method()

Hello everyone, please look at
https://metacpan.org/pod/distribution/Panda-next/lib/Panda/next.pod
i uploaded today

Currently next::method implementation is very poor.
Please look at performance of next::method in Panda::next and the new
super::subname() idiom.

I think it is reasonable to be merged into perl core.

-- 
Oleg Pronin,
CTO, Co-Founder,
Crazy Panda LTD
CP Decision LTD
0
syber
4/12/2018 4:21:28 PM
perl.perl5.porters 47364 articles. 0 followers. Follow

2 Replies
45 Views

Similar Articles

[PageSpeed] 54

On Thu, Apr 12, 2018 at 07:21:28PM +0300, Олег Пронин wrote:
> Hello everyone, please look at
> https://metacpan.org/pod/distribution/Panda-next/lib/Panda/next.pod
> i uploaded today
> 
> Currently next::method implementation is very poor.
> Please look at performance of next::method in Panda::next and the new
> super::subname() idiom.
> 
> I think it is reasonable to be merged into perl core.

Some quick comments - I haven't looked too closely at this yet.

1) I'm assuming that anything we do will be after 5.28.0 is released,
as we're 1 day away from a complete code freeze at the moment.

2) Are you suggesting that the Panda-next distribution is added to the
perl distribution as-is (like other CPAN distributions under cpan/), or
that the code and/or ideas from your distribution are used to
modify/improve the existing mro.pm/mro.xs implementation?

3) If the latter, do you expect to do this work yourself, or are you
relying on p5p to do the integration?

4) Note that some of your code is written in C++, while the perl
distribution requires only a C compiler.

5) Can you give a brief overview of how/why your re-implementation of
next::method etc is much faster?

-- 
No man treats a motor car as foolishly as he treats another human being.
When the car will not go, he does not attribute its annoying behaviour to
sin, he does not say, You are a wicked motorcar, and I shall not give you
any more petrol until you go. He attempts to find out what is wrong and
set it right.
    -- Bertrand Russell,
       Has Religion Made Useful Contributions to Civilization?
0
davem
4/19/2018 7:47:35 PM
--000000000000fcaf18056a45d0b9
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

=D1=87=D1=82, 19 =D0=B0=D0=BF=D1=80. 2018 =D0=B3. =D0=B2 22:47, Dave Mitche=
ll <davem@iabyn.com>:

> On Thu, Apr 12, 2018 at 07:21:28PM +0300, =D0=9E=D0=BB=D0=B5=D0=B3 =D0=9F=
=D1=80=D0=BE=D0=BD=D0=B8=D0=BD wrote:
> > Hello everyone, please look at
> > https://metacpan.org/pod/distribution/Panda-next/lib/Panda/next.pod
> > i uploaded today
> >
> > Currently next::method implementation is very poor.
> > Please look at performance of next::method in Panda::next and the new
> > super::subname() idiom.
> >
> > I think it is reasonable to be merged into perl core.
>
> Some quick comments - I haven't looked too closely at this yet.
>
> 1) I'm assuming that anything we do will be after 5.28.0 is released,
> as we're 1 day away from a complete code freeze at the moment.


Yeah i know


>
> 2) Are you suggesting that the Panda-next distribution is added to the
> perl distribution as-is (like other CPAN distributions under cpan/), or
> that the code and/or ideas from your distribution are used to
> modify/improve the existing mro.pm/mro.xs implementation?


None of these. The best approach is to add OPs in perl for next method
family. As a fallback approach, i can move code in mro.xs, overwriting the
old implementation, however as you may see, mro.xs is not a separate
implementation, it uses mro next cache which is in perl core code. This is
not good)


>
> 3) If the latter, do you expect to do this work yourself, or are you
> relying on p5p to do the integration?


We can implement any variant by ourselves


>
> 4) Note that some of your code is written in C++, while the perl
> distribution requires only a C compiler.


I didnt say that we will move it as is, of course i know that.


>
> 5) Can you give a brief overview of how/why your re-implementation of
> next::method etc is much faster?


Short answer: mro.xs is a dumb code))

>
1) mro.xs uses gv_efullname3 which creates tempopary sv and concats a lot,
making FQN for method name. On every call! And that FQN even is not a
shared COW hash.

2) mro.xs uses sub calls - _nextcan is a perl sub. Moreover it even somewhy
wraps it in additional perl sub call (next::method) ! 2 useless sub calls
on every call)

3) does a lot of various runtime work, which could be done only once and
cached.

If we make next:: family an OPs, a lot of things will get easier (much
easier than Panda::next has to do), for example put shared cow FQN in METHO=
P

Additionaly i think that perl needs super::* approach (next method which
follows your MRO)
This is a new concept and i=E2=80=99m not sure about correct namespace (sup=
er).
NEXT is occupied. Variant were =E2=80=9Cnextmro::method, mronext::method=E2=
=80=9D,
=E2=80=9Cnext::subname=E2=80=9D (but this will clash with next::method on m=
ethod =E2=80=9Cmethod=E2=80=9D)


>
> --
> No man treats a motor car as foolishly as he treats another human being.
> When the car will not go, he does not attribute its annoying behaviour to
> sin, he does not say, You are a wicked motorcar, and I shall not give you
> any more petrol until you go. He attempts to find out what is wrong and
> set it right.
>     -- Bertrand Russell,
>        Has Religion Made Useful Contributions to Civilization?
>
--=20
Oleg Pronin,
CTO, Co-Founder,
Crazy Panda LTD
CP Decision LTD

--000000000000fcaf18056a45d0b9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div><br><div class=3D"gmail_quote"><div dir=3D"auto">=D1=87=D1=82, 19 =D0=
=B0=D0=BF=D1=80. 2018 =D0=B3. =D0=B2 22:47, Dave Mitchell &lt;<a href=3D"ma=
ilto:davem@iabyn.com">davem@iabyn.com</a>&gt;:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">On Thu, Apr 12, 2018 at 07:21:28PM +0300, =D0=9E=D0=BB=D0=B5=
=D0=B3 =D0=9F=D1=80=D0=BE=D0=BD=D0=B8=D0=BD wrote:<br>
&gt; Hello everyone, please look at<br>
&gt; <a href=3D"https://metacpan.org/pod/distribution/Panda-next/lib/Panda/=
next.pod" rel=3D"noreferrer" target=3D"_blank">https://metacpan.org/pod/dis=
tribution/Panda-next/lib/Panda/next.pod</a><br>
&gt; i uploaded today<br>
&gt; <br>
&gt; Currently next::method implementation is very poor.<br>
&gt; Please look at performance of next::method in Panda::next and the new<=
br>
&gt; super::subname() idiom.<br>
&gt; <br>
&gt; I think it is reasonable to be merged into perl core.<br>
<br>
Some quick comments - I haven&#39;t looked too closely at this yet.<br>
<br>
1) I&#39;m assuming that anything we do will be after 5.28.0 is released,<b=
r>
as we&#39;re 1 day away from a complete code freeze at the moment.</blockqu=
ote><div dir=3D"auto"><br></div><div dir=3D"auto">Yeah i know</div><div dir=
=3D"auto"><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
2) Are you suggesting that the Panda-next distribution is added to the<br>
perl distribution as-is (like other CPAN distributions under cpan/), or<br>
that the code and/or ideas from your distribution are used to<br>
modify/improve the existing <a href=3D"http://mro.pm/mro.xs" rel=3D"norefer=
rer" target=3D"_blank">mro.pm/mro.xs</a> implementation?</blockquote><div d=
ir=3D"auto"><br></div><div dir=3D"auto">None of these. The best approach is=
 to add OPs in perl for next method family. As a fallback approach, i can m=
ove code in mro.xs, overwriting the old implementation, however as you may =
see, mro.xs is not a separate implementation, it uses mro next cache which =
is in perl core code. This is not good)=C2=A0</div><div dir=3D"auto"><br></=
div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><br>
<br>
3) If the latter, do you expect to do this work yourself, or are you<br>
relying on p5p to do the integration?</blockquote><div dir=3D"auto"><br></d=
iv><div dir=3D"auto">We can implement any variant by ourselves</div><div di=
r=3D"auto"><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 =
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
4) Note that some of your code is written in C++, while the perl<br>
distribution requires only a C compiler.</blockquote><div dir=3D"auto"><br>=
</div><div dir=3D"auto">I didnt say that we will move it as is, of course i=
 know that.</div><div dir=3D"auto"><br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><br>
<br>
5) Can you give a brief overview of how/why your re-implementation of<br>
next::method etc is much faster?</blockquote><div dir=3D"auto"><br></div><d=
iv dir=3D"auto">Short answer: mro.xs is a dumb code))</div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"></blockquote><div dir=3D"auto"><br></div><div dir=3D"auto">1=
) mro.xs uses gv_efullname3 which creates tempopary sv and concats a lot, m=
aking FQN for method name. On every call! And that FQN even is not a shared=
 COW hash.</div><div dir=3D"auto"><br></div><div dir=3D"auto">2) mro.xs use=
s sub calls - _nextcan is a perl sub. Moreover it even somewhy wraps it in =
additional perl sub call (next::method) ! 2 useless sub calls on every call=
)</div><div dir=3D"auto"><br></div><div dir=3D"auto">3) does a lot of vario=
us runtime work, which could be done only once and cached.</div><div dir=3D=
"auto"><br></div><div dir=3D"auto">If we make next:: family an OPs, a lot o=
f things will get easier (much easier than Panda::next has to do), for exam=
ple put shared cow FQN in METHOP</div><div dir=3D"auto"><br></div><div dir=
=3D"auto">Additionaly i think that perl needs super::* approach (next metho=
d which follows your MRO)</div><div dir=3D"auto">This is a new concept and =
i=E2=80=99m not sure about correct namespace (super). NEXT is occupied. Var=
iant were =E2=80=9Cnextmro::method, mronext::method=E2=80=9D, =E2=80=9Cnext=
::subname=E2=80=9D (but this will clash with next::method on method =E2=80=
=9Cmethod=E2=80=9D)</div><div dir=3D"auto"><br></div><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><br>
<br>
-- <br>
No man treats a motor car as foolishly as he treats another human being.<br=
>
When the car will not go, he does not attribute its annoying behaviour to<b=
r>
sin, he does not say, You are a wicked motorcar, and I shall not give you<b=
r>
any more petrol until you go. He attempts to find out what is wrong and<br>
set it right.<br>
=C2=A0 =C2=A0 -- Bertrand Russell,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0Has Religion Made Useful Contributions to Civili=
zation?<br>
</blockquote></div></div>-- <br><div dir=3D"ltr" class=3D"gmail_signature" =
data-smartmail=3D"gmail_signature">Oleg Pronin,<br>CTO, Co-Founder,<br>Craz=
y Panda LTD<br>CP Decision LTD<br></div>

--000000000000fcaf18056a45d0b9--
0
syber
4/20/2018 11:16:04 AM
Reply: