[Vm-dev] Class checks in the vm

Igor Stasenko siguctua at gmail.com
Tue Apr 17 17:33:16 UTC 2012


On 17 April 2012 19:14, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
>
>
> On Tue, Apr 17, 2012 at 9:54 AM, Igor Stasenko <siguctua at gmail.com> wrote:
>>
>>
>> Performance, yes...
>>
>> But i wonder, how much performance we will lose by having more
>> flexible implementation for ByteString..
>>
>> So, here what i did:
>>
>> ByteString>>bat: index put: aCharacter
>>
>>        ^ aCharacter putIntoByteString: self at: index
>>
>> Character>>putIntoByteString: string at: index
>>
>>        ^ value < 256
>>                ifTrue: [ string basicAt: index put: value ]
>>                ifFalse: [  string at: index put: self ]
>>
>>
>> Now benchmark:
>>
>> | s chars |
>>
>> s := ByteString new: 1000.
>> chars := (1 to: 255) collect: [:i | Character value: i ].
>>
>> [
>> 1 to: 1000 do: [:i |
>>        chars do: [:char| s at: i put: char ]
>>        ].
>> ] bench
>>
>>  '105 per second.'
>>
>> | s chars |
>>
>> s := ByteString new: 1000.
>> chars := (1 to: 255) collect: [:i | Character value: i ].
>>
>> [
>> 1 to: 1000 do: [:i |
>>        chars do: [:char| s bat: i put: char ]
>>        ].
>> ] bench
>>
>>
>>  '91.9 per second.'
>>
>> ~10%...
>>
>> Such kind of difference is IMO laughable,
>
>
> I disagree.  10% is a significant loss of performance.  It can take huge effort to gain 10% in a VM implementation.  It is not at all laughable.  Cog is significantly faster than the Interpreter (by factors of 3 or 5).  And that performance difference is worth-while.  The straw man below isn't a convincing argument either.  I don't see what is wrong with using a slower more flexible VM for bootstrapping (or indeed a simulation, or ...).  But do we really have to spend time arguing this point?  If you think you can do better, then  do so.  Build a more flexible VM.  Then we can compare the two.

Calm down, Eliot. I am not challenging and don't want to be
challenged. Yes, we can squeeze 1 or 2 % here and there, but at costs
of having additional constraints/contracts like compact classes,
ifTrue/ifFalse inlining etc.. which , if we follow that path all the
way, we end up with strongly typed system like C or Java and little
room for smalltalk powers.

The good question is where to put optimizations to not constrain the
system more than necessary and do not sacrifice flexibility in favor
of speed.

-- 
Best regards,
Igor Stasenko.


More information about the Vm-dev mailing list