[squeak-dev] 32 most frequent selectors

Ralph Boland rpboland at gmail.com
Thu Nov 18 15:58:15 UTC 2010


On 17.11.2010, at 06:52, Levente Uzonyi wrote:

> Also the 32 most frequently used methods are not the 32 special selectors.
>
> | b mostFrequentSelectors specialSelectors |
> b := Bag new.
> CompiledMethod allInstancesDo: [ :method | b addAll: method messages ].
> mostFrequentSelectors := (b sortedCounts first: 32) replace: #value.
> specialSelectors := Smalltalk specialSelectors select: #isSymbol.
> {
>        specialSelectors difference: mostFrequentSelectors. "Shouldn't be special"
>        mostFrequentSelectors difference: specialSelectors. "Should be special"
> }.
>
> #(
>       #(#'>=' #'~=' #/ #'\\' #bitShift: #'//' #bitAnd: #bitOr: #next #atEnd #blockCopy: #value #value: #x #y)
>       #(#, #assert: #first #name #add: #nextPutAll: #isEmpty #error: #asString #includes: #default #translated #not #on: #collect:))

This analysis reflects the most frequent selectors in terms of space used
but that is not the only consideration.  Also of some importance is the time
consumed which depends upon how often the selectors are sent
and also on the time savings in making them special.
I admit I am not sure how we make this time/space trade off.
In particular, the time cost may be heavily
dependent upon the application (or not).

And there are other considerations.  For examples:

   #assert may be used a lot in development software but not in production code.
   So, in my opinion, regardless of its use frequency, it should not be special.
   In fact, in production code it might not be used at all.

  Some selectors such as #bitShift:, #bitAnd:, and  #bitOr:  I expect must be,
  or must reasonably be, implemented in the virtual machine regardless of usage.

  Some selectors, though not often used, may be used in applications where
  requirements put their performance at a premium.  I am being redundant
  here in that I think this example applies mostly to selectors
  #bitShift:, #bitAnd:, and  #bitOr:


Regards,

Ralph Boland



More information about the Squeak-dev mailing list