[Vm-dev] how slower is called a named primitive over a numbered primitive?

Eliot Miranda eliot.miranda at gmail.com
Tue Jun 23 23:38:53 UTC 2015


On Tue, Jun 23, 2015 at 12:33 PM, Bert Freudenberg <bert at freudenbergs.de>
wrote:

>
> On 23.06.2015, at 18:23, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> >
> > Hi Bert,
> >
> > On Jun 23, 2015, at 3:38 AM, Bert Freudenberg <bert at freudenbergs.de>
> wrote:
> >
> >> On 23.06.2015, at 02:58, David T. Lewis <lewis at mail.msen.com> wrote:
> >>> On an interpreter VM, the results are as Tim and I initially expected:
> >>>
> >>> | i | i := SmallInteger maxVal + 1.
> >>> (1 to: 6) collect: [:j| {[1 to: 10000000 do: [:k| i numberedLessThan:
> i]]
> >>> timeToRun. [1 to: 10000000 do: [:k| i namedLessThan: i]] timeToRun}]
> >>>
> >>> ==> #(#(791 789) #(793 794) #(793 790) #(791 791) #(790 794) #(795
> 789))
> >>>
> >>> With a Cog VM, the numbered primitives are significantly faster:
> >>>
> >>> | i | i := SmallInteger maxVal + 1.
> >>> (1 to: 6) collect: [:j| {[1 to: 10000000 do: [:k| i numberedLessThan:
> i]]
> >>> timeToRun. [1 to: 10000000 do: [:k| i namedLessThan: i]] timeToRun}]
> >>>
> >>> ==> #(#(542 670) #(542 668) #(544 678) #(546 680) #(540 666) #(540
> 680))
> >>
> >> Looks like SqueakJS may need some caching for named prim lookup:
> >>
> >> ((54 535 ) (42 541 ) (42 536 ) (49 542 ) (44 527 ) (44 530 ) )
> >
> >
> > I think this is an inlined apples vs oranges comparison :).  To be that
> fast surely the JS VM has optimized away the numbered primitive send
> entirely, leaving only the named primitive send, so this isn't the
> difference between the two at all.
>
> Haha, no. I removed two zeroes from the iteration count ;)
>

ROTFL :)
-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20150623/e73f8f1c/attachment.htm


More information about the Vm-dev mailing list