[squeak-dev] The Trunk: Collections-nice.582.mcz

Eliot Miranda eliot.miranda at gmail.com
Sat Sep 20 22:22:53 UTC 2014


Hi Levente,

On Sat, Sep 20, 2014 at 8:24 AM, Levente Uzonyi <leves at elte.hu> wrote:

> Cool. I think the spaceship operator for strings should use
> #compare:with:collated: to save a comparison in the most common case.
>
> The performance of symbols would be close to dyadic blocks, if it were
> cheap and easy to create a block on the fly.
>

I don't know what cheap enough in this case is but Spur is over 5 times
faster at creating blocks than the existing Cog V3 VM:


[1 to: 1,000,000,000 do: [:i| [nil class]]] timeToRun

Spur: 5,950ms
Cog: 31,951ms

31951 / 5950.0                 5.37
5950 - 31951 / 319.51    -81.4%

So ignoring the loop overhead, Spur creates a block in less than 6
nanoseconds on a 2.2GHz MBP Core i7.


A slightly more realistic example which creates a new home context for
every block created is


[1 to: 10,000,000 do: [:i| [[nil class]] value. [[nil class]] value. [[nil
class]] value. [[nil class]] value. [[nil class]] value. [[nil class]]
value. [[nil class]] value. [[nil class]] value. [[nil class]] value. [[nil
class]] value.]] timeToRun

Spur: 2,568ms
Cog: 11,601ms

11601 / 2568.0 4.51752336448598
2568 - 11601 / 116.01 -77.8639772433411

So here Spur creates two closures and a context in 2.568 / 100,000,000 = 26
nsecs, compared to 160 for Cog V3.

Levente
>
> On Fri, 19 Sep 2014, commits at source.squeak.org wrote:
>
>  Nicolas Cellier uploaded a new version of Collections to project The
>> Trunk:
>> http://source.squeak.org/trunk/Collections-nice.582.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Collections-nice.582
>> Author: nice
>> Time: 19 September 2014, 10:22:13.338 pm
>> UUID: 52a598f1-224e-4649-a95f-4e78547b5ed5
>> Ancestors: Collections-nice.581
>>
>> Port TAG-SortFunctions of Travis Griggs from Cincom public store -
>> version (11,tgriggs)
>>
>> Note that no collation policy were used for String.
>> The spaceship operator <=> is also required in Kernel-Numbers.
>>
>> See also the blog http://objology.blogspot.fr/
>> 2010/11/tag-sortfunctions.html
>> and http://objology.blogspot.fr/2010/11/tag-sortfunctions-redux.html
>>
>> Note about the cost of these sort functions:
>> as shown by this mini-bench on cog, using a Symbol costs a bit more
>> (perform:) than a block activation, and monadic block a bit more than
>> dyadic one because activated twice more, but it seems acceptable to me with
>> regard to the great simplification and expressiveness of code :
>>
>> | collec1 collec2 collec3 |
>> collec1 := (1 to: 200000) collect: [:i | 1000000 atRandom-500000].
>> collec2 := collec1 copy.
>> collec3 := collec1 copy.
>> {
>> [collec1 sort: [:a :b | a abs < b abs]] timeToRun.
>> [collec2 sort: [:e | e abs] ascending] timeToRun.
>> [collec3 sort: #abs ascending] timeToRun.
>> }
>> #(345 532 912)
>>
>>
>


-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140920/8e41c3c1/attachment.htm


More information about the Squeak-dev mailing list