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

Eliot Miranda eliot.miranda at gmail.com
Tue Jun 23 16:23:55 UTC 2015


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.

> - Bert -
> 


More information about the Vm-dev mailing list