[Vm-dev] Class checks in the vm

Eliot Miranda eliot.miranda at gmail.com
Tue Apr 17 17:14:53 UTC 2012


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.




> taking into account the
> a) more flexibility
> b) less VM complexity
>
>
> Another benchmark:
>
> | s |
>
> s := ByteString new: 1000.
> [
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
>        s at: 1 put: $A.
> ] bench
>  '1,530,000 per second.'
>
> | s |
>
> s := ByteString new: 1000.
> [
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
>        s bat: 1 put: $A.
> ] bench
>  '1,310,000 per second.'
>
>
> Frankly, i expected much , much more difference. So, i think in this
> case we can safely discard the performance argument(s).
>
> --
> Best regards,
> Igor Stasenko.
>



-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20120417/917152d3/attachment.htm


More information about the Vm-dev mailing list