faster sets project

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

faster sets project

Ralph Boland
I recently released a project called FasterSets into the Squeak repository and
am trying to get it incorporated into the Squeak (and Pharo) base image.
Pharo looks like a go;  Squeak seems to move a little slower.

Meanwhile, my long term plan is to get FasterSets incorporated into all versions
of Smaltalk that I can, including of course, GNU Smalltalk; hence this posting.

The Idea behind FasterSets is to not do any element compares during a Set
(or any of its subclasses) grow operation; since during a grow operation
we know all the elements being added to the set are not already there and
so no compares are needed.  In Squeak this modification results in a reduction
in the average number of element compares during an add: operation of
around  14% (min 7% max 21%).

I see 4 scenarios:

1)  GNU Smalltalk does not want FasterSets.  FasterSets affects low level
      methods in class Set and its subclasses and can break user classes that
      are subclasses of Set and which override these same low level methods.
      (In Pharo FasterSets was tested against a number of packages including
      Seaside without problems.)

2)  In GNU Smalltalk Sets already work this way so there is no need
for FasterSets.

3)  FasterSets is a great idea.  But we want a GNU Smalltalk guru to implement
     this idea from scratch.  It is a simple idea after all.  Thanks
for the idea though.

4)  FasterSets is a great idea.  The originator (me) will create a
project in GNU
     Smalltalk containing the code.  Note that the version of FasterSets
     to be incorporated into Squeak/Pharo will be under the MIT license but the
     version for GNU Smalltalk will be under the GNU license.
     As the creator of the software I can create different licenses
for different
     versions.  I will need to sign the GNU Smalltalk release form.
Since I have
     never used GNU Smalltalk some help with testing project releases will be
     helpful.  Someone else will do the final integration into GNU Smalltalk
     once the project is released.
     This will be a great way for me to become familiar with GNU Smalltalk.

I look forward to feedback.

Ralph Boland


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: faster sets project

Paolo Bonzini-3
 > 2)  In GNU Smalltalk Sets already work this way so there is no need
 > for FasterSets.

It's this. :-)

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: faster sets project

Ralph Boland
2009/7/14 Paolo Bonzini <[hidden email]>:
>> 2)  In GNU Smalltalk Sets already work this way so there is no need
>> for FasterSets.
>
> It's this. :-)
>
> Paolo
>

I downloaded GNU Smalltalk and checked (which I should have done in
the beginning) and determined that in fact  GNU Smalltalk Sets and
subclasses (and also Dictionary and its subclasses) do NOT
avoid element compares during a grow operation!

Thus set and dictionary adds of elements not already in the collection
can be improved to do on average 14% fewer compares.
So can I get a response on which of the remaining scenario's proposed
is  considered the best.

Regards,

Ralph Boland




>> I recently released a project called FasterSets into the Squeak repository and
>> am trying to get it incorporated into the Squeak (and Pharo) base image.
>> Pharo looks like a go;  Squeak seems to move a little slower.

>> Meanwhile, my long term plan is to get FasterSets incorporated into all versions
>> of Smaltalk that I can, including of course, GNU Smalltalk; hence this posting.

>> The Idea behind FasterSets is to not do any element compares during a Set
>> (or any of its subclasses) grow operation; since during a grow operation
>> we know all the elements being added to the set are not already there and
>> so no compares are needed.  In Squeak this modification results in a reduction
>> in the average number of element compares during an add: operation of
>> around  14% (min 7% max 21%).

Note that in Squeak  Dictionary is a subclass of Set so this improvement
applies to Dictionary and its subclasses as well!

>> I see 4 scenarios:

>> 1)  GNU Smalltalk does not want FasterSets.  FasterSets affects low level
>>      methods in class Set and its subclasses and can break user classes that
>>      are subclasses of Set and which override these same low level methods.
>>      (In Pharo FasterSets was tested against a number of packages including
>>      Seaside without problems.)


>> 2)  In GNU Smalltalk Sets already work this way so there is no need
>> for FasterSets.

HA!

>> 3)  FasterSets is a great idea.  But we want a GNU Smalltalk guru to implement
>>      this idea from scratch.  It is a simple idea after all.  Thanks
>>      for the idea though.

>> 4)  FasterSets is a great idea.  The originator (me) will create a
>>      project in GNU
>>     Smalltalk containing the code.  Note that the version of FasterSets
>>     to be incorporated into Squeak/Pharo will be under the MIT license but the
>>     version for GNU Smalltalk will be under the GNU license.
>>     As the creator of the software I can create different licenses
>>     for different versions.  I will need to sign the GNU Smalltalk release form.
>>     Since I have
>>     never used GNU Smalltalk some help with testing project releases will be
>>     helpful.  Someone else will do the final integration into GNU Smalltalk
>>     once the project is released.
>>     This will be a great way for me to become familiar with GNU Smalltalk.

>> I look forward to feedback.

>> Ralph Boland


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: faster sets project

MrGwen
On Friday 17 July 2009 01:17:24 Ralph Boland wrote:

> 2009/7/14 Paolo Bonzini <[hidden email]>:
> >> 2)  In GNU Smalltalk Sets already work this way so there is no need
> >> for FasterSets.
> >
> > It's this. :-)
> >
> > Paolo
>
> I downloaded GNU Smalltalk and checked (which I should have done in
> the beginning) and determined that in fact  GNU Smalltalk Sets and
> subclasses (and also Dictionary and its subclasses) do NOT
> avoid element compares during a grow operation!
>
> Thus set and dictionary adds of elements not already in the collection
> can be improved to do on average 14% fewer compares.
> So can I get a response on which of the remaining scenario's proposed
> is  considered the best.
>
> Regards,
>
> Ralph Boland
>
> >> I recently released a project called FasterSets into the Squeak
> >> repository and am trying to get it incorporated into the Squeak (and
> >> Pharo) base image. Pharo looks like a go;  Squeak seems to move a little
> >> slower.
> >>
> >> Meanwhile, my long term plan is to get FasterSets incorporated into all
> >> versions of Smaltalk that I can, including of course, GNU Smalltalk;
> >> hence this posting.
> >>
> >> The Idea behind FasterSets is to not do any element compares during a
> >> Set (or any of its subclasses) grow operation; since during a grow
> >> operation we know all the elements being added to the set are not
> >> already there and so no compares are needed.  In Squeak this
> >> modification results in a reduction in the average number of element
> >> compares during an add: operation of around  14% (min 7% max 21%).
>
> Note that in Squeak  Dictionary is a subclass of Set so this improvement
> applies to Dictionary and its subclasses as well!
>
> >> I see 4 scenarios:
> >>
> >> 1)  GNU Smalltalk does not want FasterSets.  FasterSets affects low
> >> level methods in class Set and its subclasses and can break user classes
> >> that are subclasses of Set and which override these same low level
> >> methods. (In Pharo FasterSets was tested against a number of packages
> >> including Seaside without problems.)
> >>
> >>
> >> 2)  In GNU Smalltalk Sets already work this way so there is no need
> >> for FasterSets.
>
> HA!
>
> >> 3)  FasterSets is a great idea.  But we want a GNU Smalltalk guru to
> >> implement this idea from scratch.  It is a simple idea after all.
> >> Thanks for the idea though.
> >>
> >> 4)  FasterSets is a great idea.  The originator (me) will create a
> >>      project in GNU
> >>     Smalltalk containing the code.  Note that the version of FasterSets
> >>     to be incorporated into Squeak/Pharo will be under the MIT license
> >> but the version for GNU Smalltalk will be under the GNU license.
> >>     As the creator of the software I can create different licenses
> >>     for different versions.  I will need to sign the GNU Smalltalk
> >> release form. Since I have
> >>     never used GNU Smalltalk some help with testing project releases
> >> will be helpful.  Someone else will do the final integration into GNU
> >> Smalltalk once the project is released.
> >>     This will be a great way for me to become familiar with GNU
> >> Smalltalk.
> >>
> >> I look forward to feedback.
> >>
> >> Ralph Boland
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> http://lists.gnu.org/mailman/listinfo/help-smalltalk
May be you can look at HashedCollection (the superclass of Dictionary and Set)

  addWhileGrowing: value [
        "Private - Add the newObject association to the receiver. Don't check for
         the set to be full - we want SPEED!."

        <category: 'private methods'>
        self primAt: (self findElementIndex: value) put: value.
        tally := tally + 1.
        ^value
    ]

(I use the GIT version of GST)

Cheers,
Gwenael


--

VisualGST for GNU Smalltalk : http://visualgst.bioskop.fr/


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: faster sets project

Paolo Bonzini-3

> May be you can look at HashedCollection (the superclass of Dictionary and Set)
>
>    addWhileGrowing: value [
> "Private - Add the newObject association to the receiver. Don't check for
> the set to be full - we want SPEED!."
>
> <category: 'private methods'>
> self primAt: (self findElementIndex: value) put: value.
> tally := tally + 1.
> ^value
>      ]

     findElementIndex: anObject [
         "Tries to see where anObject can be placed as an indexed variable.
          As soon as nil is found, the index of that slot is answered.
          anObject also comes from an indexed variable."

         <category: 'private methods'>
         | index size element |
         self beConsistent.

         "Sorry for the lack of readability, but I want speed... :-)"
         index := (anObject hash scramble bitAnd: (size := self
primSize) - 1) + 1.

         [(element := self primAt: index) isNil
             ifTrue: [^index].
         index == size ifTrue: [index := 1] ifFalse: [index := index + 1]]
                 repeat
     ]


> (I use the GIT version of GST)

I think this has been there for years.

(Ralph, no offense intended of course.  I understand the difficulty in
reading a complex system and I understand you are used to having a
browser.  Luckily it's just a few months away... ;-)

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk