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

Bert Freudenberg bert at freudenbergs.de
Tue Jun 23 19:33:44 UTC 2015


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 ;)

- Bert -

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4115 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20150623/14dd5f81/smime.bin


More information about the Vm-dev mailing list