Discussion:
[squeak-dev] The Inbox: Collections-cbc.810.mcz
c***@source.squeak.org
0000-10-30 06:07:06 UTC
Permalink
Chris Cunningham uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-cbc.810.mcz

==================== Summary ====================

Name: Collections-cbc.810
Author: cbc
Time: 28 October 2018, 5:15:56.960512 pm
UUID: 729c4dd2-f677-3c40-9ded-4a407a71f824
Ancestors: Collections-topa.809

Do NOT move to trunk!
Various option for fixing the internval hash issue related to collectionsTests cbc.296.

Some explanation to go to mailing list - this is so interested folks can try out the code.

=============== Diff against Collections-topa.809 ===============

Item was added:
+ ----- Method: Array>>hashBetterFastIntervalCompatible (in category 'comparing') -----
+ hashBetterFastIntervalCompatible
+ | hash |
+ self size < 48 ifTrue: [^super hash]. "Just check every element."
+ hash := self species hash.
+ 1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ self size - 15 to: self size do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ ^(hash + self size hash) hashMultiply!

Item was added:
+ ----- Method: Array>>hashFastIntervalCompatible (in category 'comparing') -----
+ hashFastIntervalCompatible
+ self size = 0 ifTrue: [^self species hash].
+ ^(self species hash +
+ (((((self at: 1) hash bitShift: 2)
+ bitOr: (self at: self size) hash)
+ bitShift: 1)
+ bitOr: self size)
+ ) hashMultiply!

Item was changed:
----- Method: Interval>>hash (in category 'comparing') -----
hash
"Hash is reimplemented because = is implemented."

^(((start hash bitShift: 2)
bitOr: stop hash)
bitShift: 1)
bitOr: self size!

Item was added:
+ ----- Method: Interval>>hashBetter (in category 'comparing') -----
+ hashBetter
+ "Hash is reimplemented because = is implemented."
+
+ ^(((start hash bitShift: 2)
+ bitOr: self last hash)
+ bitShift: 1)
+ bitOr: self size!

Item was added:
+ ----- Method: Interval>>hashBetterAlsoFixBug3380 (in category 'comparing') -----
+ hashBetterAlsoFixBug3380
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ ^self inject: Array hash into: [:workingHash :each| (workingHash + each hash) hashMultiply ].!

Item was added:
+ ----- Method: Interval>>hashBetterFastArrayCompatible (in category 'comparing') -----
+ hashBetterFastArrayCompatible
+ | hash |
+ self size < 48 ifTrue: [^self slowHash]. "Just check every element."
+ hash := Array hash.
+ 1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ self size - 15 to: self size do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ ^(hash + self size hash) hashMultiply!

Item was added:
+ ----- Method: Interval>>hashFastArrayCompatible (in category 'comparing') -----
+ hashFastArrayCompatible
+ "Hash is reimplemented because = is implemented."
+ self size = 0 ifTrue: [^Array hash].
+ ^(Array hash +
+ ((((start hash bitShift: 2)
+ bitOr: self last hash)
+ bitShift: 1)
+ bitOr: self size)
+ ) hashMultiply!

Item was added:
+ ----- Method: Interval>>hashSlowerBetterAlsoFixBug3380 (in category 'comparing') -----
+ hashSlowerBetterAlsoFixBug3380
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ | hash |
+
+ hash := Array hash.
+ 1 to: self size do: [:i | hash := (hash + (self at: i) hash) hashMultiply].
+ ^hash!

Item was added:
+ ----- Method: Interval>>slowHash (in category 'comparing') -----
+ slowHash
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ ^self inject: Array hash into: [:workingHash :each| (workingHash + each hash) hashMul
Nicolas Cellier
2018-10-29 19:36:24 UTC
Permalink
Is Interval = Array such an important feature?
My opinion now is that we should rather abandon it.
Post by c***@source.squeak.org
http://source.squeak.org/inbox/Collections-cbc.810.mcz
==================== Summary ====================
Name: Collections-cbc.810
Author: cbc
Time: 28 October 2018, 5:15:56.960512 pm
UUID: 729c4dd2-f677-3c40-9ded-4a407a71f824
Ancestors: Collections-topa.809
Do NOT move to trunk!
Various option for fixing the internval hash issue related to
collectionsTests cbc.296.
Some explanation to go to mailing list - this is so interested folks can try out the code.
=============== Diff against Collections-topa.809 ===============
+ ----- Method: Array>>hashBetterFastIntervalCompatible (in category 'comparing') -----
+ hashBetterFastIntervalCompatible
+ | hash |
+ self size < 48 ifTrue: [^super hash]. "Just check every element."
+ hash := self species hash.
+ 1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ self size - 15 to: self size do: [:i| hash := (hash + (self at: i)
hash) hashMultiply].
+ ^(hash + self size hash) hashMultiply!
+ ----- Method: Array>>hashFastIntervalCompatible (in category
'comparing') -----
+ hashFastIntervalCompatible
+ self size = 0 ifTrue: [^self species hash].
+ ^(self species hash +
+ (((((self at: 1) hash bitShift: 2)
+ bitOr: (self at: self size) hash)
+ bitShift: 1)
+ bitOr: self size)
+ ) hashMultiply!
----- Method: Interval>>hash (in category 'comparing') -----
hash
"Hash is reimplemented because = is implemented."
^(((start hash bitShift: 2)
bitOr: stop hash)
bitShift: 1)
bitOr: self size!
+ ----- Method: Interval>>hashBetter (in category 'comparing') -----
+ hashBetter
+ "Hash is reimplemented because = is implemented."
+
+ ^(((start hash bitShift: 2)
+ bitOr: self last hash)
+ bitShift: 1)
+ bitOr: self size!
+ ----- Method: Interval>>hashBetterAlsoFixBug3380 (in category 'comparing') -----
+ hashBetterAlsoFixBug3380
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ ^self inject: Array hash into: [:workingHash :each| (workingHash +
each hash) hashMultiply ].!
+ ----- Method: Interval>>hashBetterFastArrayCompatible (in category 'comparing') -----
+ hashBetterFastArrayCompatible
+ | hash |
+ self size < 48 ifTrue: [^self slowHash]. "Just check every
element."
+ hash := Array hash.
+ 1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ self size - 15 to: self size do: [:i| hash := (hash + (self at: i)
hash) hashMultiply].
+ ^(hash + self size hash) hashMultiply!
+ ----- Method: Interval>>hashFastArrayCompatible (in category
'comparing') -----
+ hashFastArrayCompatible
+ "Hash is reimplemented because = is implemented."
+ self size = 0 ifTrue: [^Array hash].
+ ^(Array hash +
+ ((((start hash bitShift: 2)
+ bitOr: self last hash)
+ bitShift: 1)
+ bitOr: self size)
+ ) hashMultiply!
+ ----- Method: Interval>>hashSlowerBetterAlsoFixBug3380 (in category 'comparing') -----
+ hashSlowerBetterAlsoFixBug3380
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ | hash |
+
+ hash := Array hash.
+ 1 to: self size do: [:i | hash := (hash + (self at: i) hash)
hashMultiply].
+ ^hash!
+ ----- Method: Interval>>slowHash (in category 'comparing') -----
+ slowHash
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ ^self inject: Array hash into: [:workingHash :each| (workingHash +
each hash) hashMultiply ].!
Eliot Miranda
2018-10-30 00:47:44 UTC
Permalink
On Mon, Oct 29, 2018 at 12:36 PM Nicolas Cellier <
Post by Nicolas Cellier
Is Interval = Array such an important feature?
My opinion now is that we should rather abandon it.
+1
Post by Nicolas Cellier
Post by c***@source.squeak.org
http://source.squeak.org/inbox/Collections-cbc.810.mcz
==================== Summary ====================
Name: Collections-cbc.810
Author: cbc
Time: 28 October 2018, 5:15:56.960512 pm
UUID: 729c4dd2-f677-3c40-9ded-4a407a71f824
Ancestors: Collections-topa.809
Do NOT move to trunk!
Various option for fixing the internval hash issue related to
collectionsTests cbc.296.
Some explanation to go to mailing list - this is so interested folks can
try out the code.
=============== Diff against Collections-topa.809 ===============
+ ----- Method: Array>>hashBetterFastIntervalCompatible (in category 'comparing') -----
+ hashBetterFastIntervalCompatible
+ | hash |
+ self size < 48 ifTrue: [^super hash]. "Just check every element."
+ hash := self species hash.
+ 1 to: 16 do: [:i| hash := (hash + (self at: i) hash)
hashMultiply].
i) hash) hashMultiply].
+ ^(hash + self size hash) hashMultiply!
+ ----- Method: Array>>hashFastIntervalCompatible (in category 'comparing') -----
+ hashFastIntervalCompatible
+ self size = 0 ifTrue: [^self species hash].
+ ^(self species hash +
+ (((((self at: 1) hash bitShift: 2)
+ bitOr: (self at: self size) hash)
+ bitShift: 1)
+ bitOr: self size)
+ ) hashMultiply!
----- Method: Interval>>hash (in category 'comparing') -----
hash
"Hash is reimplemented because = is implemented."
^(((start hash bitShift: 2)
bitOr: stop hash)
bitShift: 1)
bitOr: self size!
+ ----- Method: Interval>>hashBetter (in category 'comparing') -----
+ hashBetter
+ "Hash is reimplemented because = is implemented."
+
+ ^(((start hash bitShift: 2)
+ bitOr: self last hash)
+ bitShift: 1)
+ bitOr: self size!
+ ----- Method: Interval>>hashBetterAlsoFixBug3380 (in category 'comparing') -----
+ hashBetterAlsoFixBug3380
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ ^self inject: Array hash into: [:workingHash :each| (workingHash
+ each hash) hashMultiply ].!
+ ----- Method: Interval>>hashBetterFastArrayCompatible (in category 'comparing') -----
+ hashBetterFastArrayCompatible
+ | hash |
+ self size < 48 ifTrue: [^self slowHash]. "Just check every
element."
+ hash := Array hash.
+ 1 to: 16 do: [:i| hash := (hash + (self at: i) hash)
hashMultiply].
i) hash) hashMultiply].
+ ^(hash + self size hash) hashMultiply!
+ ----- Method: Interval>>hashFastArrayCompatible (in category 'comparing') -----
+ hashFastArrayCompatible
+ "Hash is reimplemented because = is implemented."
+ self size = 0 ifTrue: [^Array hash].
+ ^(Array hash +
+ ((((start hash bitShift: 2)
+ bitOr: self last hash)
+ bitShift: 1)
+ bitOr: self size)
+ ) hashMultiply!
+ ----- Method: Interval>>hashSlowerBetterAlsoFixBug3380 (in category 'comparing') -----
+ hashSlowerBetterAlsoFixBug3380
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ | hash |
+
+ hash := Array hash.
+ 1 to: self size do: [:i | hash := (hash + (self at: i) hash)
hashMultiply].
+ ^hash!
+ ----- Method: Interval>>slowHash (in category 'comparing') -----
+ slowHash
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ ^self inject: Array hash into: [:workingHash :each| (workingHash
+ each hash) hashMultiply ].!
--
_,,,^..^,,,_
best, Eliot
Chris Muller
2018-10-30 04:04:16 UTC
Permalink
Good finds and also this analysis of trade-off implementations for
Interval>>#hash! I definitely don't understand the implications of
each ("size - 15"?), but this cool try-it-out package enables a level
of collaboration that almost brings a tear to my eye. Awesome.

Thanks Chris. :)
Post by c***@source.squeak.org
http://source.squeak.org/inbox/Collections-cbc.810.mcz
==================== Summary ====================
Name: Collections-cbc.810
Author: cbc
Time: 28 October 2018, 5:15:56.960512 pm
UUID: 729c4dd2-f677-3c40-9ded-4a407a71f824
Ancestors: Collections-topa.809
Do NOT move to trunk!
Various option for fixing the internval hash issue related to collectionsTests cbc.296.
Some explanation to go to mailing list - this is so interested folks can try out the code.
=============== Diff against Collections-topa.809 ===============
+ ----- Method: Array>>hashBetterFastIntervalCompatible (in category 'comparing') -----
+ hashBetterFastIntervalCompatible
+ | hash |
+ self size < 48 ifTrue: [^super hash]. "Just check every element."
+ hash := self species hash.
+ 1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ self size - 15 to: self size do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ ^(hash + self size hash) hashMultiply!
+ ----- Method: Array>>hashFastIntervalCompatible (in category 'comparing') -----
+ hashFastIntervalCompatible
+ self size = 0 ifTrue: [^self species hash].
+ ^(self species hash +
+ (((((self at: 1) hash bitShift: 2)
+ bitOr: (self at: self size) hash)
+ bitShift: 1)
+ bitOr: self size)
+ ) hashMultiply!
----- Method: Interval>>hash (in category 'comparing') -----
hash
"Hash is reimplemented because = is implemented."
^(((start hash bitShift: 2)
bitOr: stop hash)
bitShift: 1)
bitOr: self size!
+ ----- Method: Interval>>hashBetter (in category 'comparing') -----
+ hashBetter
+ "Hash is reimplemented because = is implemented."
+
+ ^(((start hash bitShift: 2)
+ bitOr: self last hash)
+ bitShift: 1)
+ bitOr: self size!
+ ----- Method: Interval>>hashBetterAlsoFixBug3380 (in category 'comparing') -----
+ hashBetterAlsoFixBug3380
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ ^self inject: Array hash into: [:workingHash :each| (workingHash + each hash) hashMultiply ].!
+ ----- Method: Interval>>hashBetterFastArrayCompatible (in category 'comparing') -----
+ hashBetterFastArrayCompatible
+ | hash |
+ self size < 48 ifTrue: [^self slowHash]. "Just check every element."
+ hash := Array hash.
+ 1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ self size - 15 to: self size do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
+ ^(hash + self size hash) hashMultiply!
+ ----- Method: Interval>>hashFastArrayCompatible (in category 'comparing') -----
+ hashFastArrayCompatible
+ "Hash is reimplemented because = is implemented."
+ self size = 0 ifTrue: [^Array hash].
+ ^(Array hash +
+ ((((start hash bitShift: 2)
+ bitOr: self last hash)
+ bitShift: 1)
+ bitOr: self size)
+ ) hashMultiply!
+ ----- Method: Interval>>hashSlowerBetterAlsoFixBug3380 (in category 'comparing') -----
+ hashSlowerBetterAlsoFixBug3380
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ | hash |
+
+ hash := Array hash.
+ 1 to: self size do: [:i | hash := (hash + (self at: i) hash) hashMultiply].
+ ^hash!
+ ----- Method: Interval>>slowHash (in category 'comparing') -----
+ slowHash
+ "Hash is reimplemented because = is implemented."
+ "Altered so that we has the same as self asArray hash"
+ ^self inject: Array hash into: [:workingHash :each
Loading...