Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001632 [Squeak] Kernel minor always 08-08-05 21:53 02-16-06 17:40
Reporter KenCausey View Status public  
Assigned To
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 3.9 Product Version
  Product Build
Summary 0001632: [ENH] BehaviorHashEnh
Description sr@evolgo.de:

"Change Set: BehaviorHashEnh v1.1
Date: 22 June 2004
Author: Stephan Rudlof

Improves the default Object>>hash for Behaviors by installing
Behavior>>hash. String>>hash has been changed a little to avoid infinite
recursion (without changing its semantics).
All is done in the postscript.

Important
-----------
This is a special changeset: Do not export and import this changeset
again after importing it the first time! Then the methods are not
installed alone in the postscript anymore, leading to serious problems!
-----------

Rationale: Object>>hash calling ProtoObject>>identityHash gives poor
results for Behaviors. Therefore a new Behavior>>hash using Symbol>>hash
or String>>hash (the latter slightly changed to avoide infinite
recursion) will be installed.

Consequences:
- It speeds up Set/Dictionary operations with Behaviors a lot (see
below).
- The main consequence for other objects as Behaviors seems to be a
changed hash if they use
    self species hash
as a start value for computing their hash.
But AFAICS this doesn't hurt, since in most cases (non meta classes as
species) it maps to Symbol>>hash, which is fast.

Test:
doIt
    | allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asSet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}
before and after filing in this cs.
To see the problem again just doIt
    | allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asIdentitySet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}.

Future: Best would probably be a better identityHash with more bits
(possibly in V4?).

PS: I've been stumbled over BrowserEnvironmentTest>>testAllClassesDo,
which is dog slow without this cs.

History
--------
- v1.1: changed cs comment
- without v no: original version
--------"
Steps To Reproduce
Additional Information
Attached Files  BehaviorHashEnh.cs.gz [^] (1,166 bytes) 08-08-05 21:53

- Relationships

- Notes
(0002207 - 56 - 78 - 78 - 78 - 78 - 78)
KenCausey
08-08-05 21:54

karl.ramberg@chello.se:

"[er][et][sm][cd] looks good"
 
(0002208 - 841 - 1484 - 1484 - 1484 - 1484 - 1484)
KenCausey
08-08-05 21:56

ducasse@iam.unibe.ch:

"can somebody else have a look at this enh.

I run the "tests"

| allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asSet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}
    

before and after filing in this cs.
To see the problem again just doIt
    | allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asIdentitySet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}.
    
    
after loading I got
    -> #(64 57 63)

To see the problem again just doIt
    -> #(34 33 39)
    

So I'm confused because I thought this would be the opposite so I may be
too tired."
 
(0002209 - 429 - 683 - 725 - 725 - 725 - 725)
KenCausey
08-08-05 21:57

=?ISO-8859-1?Q?st=E9phane_ducasse?= <ducasse@iam.unibe.ch>:

"with 3.8 6273

I get | allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asSet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}
  #(51 48 53)

and nearly the same in 6208

Stef

could you check because something certainly changed."
 
(0002210 - 3944 - 5797 - 5831 - 5831 - 5831 - 5831)
KenCausey
08-08-05 22:00

Stephan Rudlof <sr@evolgo.de>:

"now I've tested with Squeak3.8alpha #6285:
and the results remain the same for me as for Squeak3.7!
With fileIn of the cs or doIt of the postscript in the cs directly:
always the same.

I don't understand your results.


Please give me your results exactly as I've done them below (two doIts
before and two other ones after fileIn of the cs, the *first* and
*second* doIt (of the two) are *different*!).

I have tried to be very explicit in my explanations, sine I just have
the idea that we are testing different things.


Any other takers?

My results:

*first* doIt
    | allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asSet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}
 #(6840 6863 6823) #(6988 6907 6862) "before"
 #(199 204 200) #(203 219 206) "after fileIn"
    
*second* doIt
    | allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asIdentitySet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}.
 #(3112 3166 3108) #(3152 3160 3129) "before"
 #(3196 3225 3186) #(3193 3181 3163) "after fileIn"


My cs has been (you can also doIt the postscript manually):

'From Squeak3.7beta of ''1 April 2004'' [latest update: #5963] on 22
June 2004 at 8:51:57 pm'!
"Change Set: BehaviorHashEnh v1.1
Date: 22 June 2004
Author: Stephan Rudlof

Improves the default Object>>hash for Behaviors by installing
Behavior>>hash. String>>hash has been changed a little to avoid infinite
recursion (without changing its semantics).
All is done in the postscript.

Important
-----------
This is a special changeset: Do not export and import this changeset
again after importing it the first time!! Then the methods are not
installed alone in the postscript anymore, leading to serious problems!!
-----------

Rationale: Object>>hash calling ProtoObject>>identityHash gives poor
results for Behaviors. Therefore a new Behavior>>hash using Symbol>>hash
or String>>hash (the latter slightly changed to avoide infinite
recursion) will be installed.

Consequences:
- It speeds up Set/Dictionary operations with Behaviors a lot (see below).
- The main consequence for other objects as Behaviors seems to be a
changed hash if they use
    self species hash
as a start value for computing their hash.
But AFAICS this doesn't hurt, since in most cases (non meta classes as
species) it maps to Symbol>>hash, which is fast.

Test:
doIt
    | allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asSet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}
before and after filing in this cs.
To see the problem again just doIt
    | allClasses allClassesSet block |
    allClasses := Smalltalk allClasses.
    block _ [allClassesSet _ allClasses asIdentitySet.
            [allClasses do: [:class | allClassesSet remove: class]] timeToRun].
    {block value. block value. block value}.

Future: Best would probably be a better identityHash with more bits
(possibly in V4?).

PS: I've been stumbled over BrowserEnvironmentTest>>testAllClassesDo,
which is dog slow without this cs.

History
--------
- v1.1: changed cs comment
- without v no: original version
--------"!

"Postscript:
Compile String and Behavior >>hash here, since compilation has to be
tight together with rehashing Sets possibly containing objects with
changed >>hash."

String compile:
'hash
    "#hash is implemented, because #= is implemented"

    ^ByteArray
        hashBytes: self
        startingWith: self species identityHash'.
            
Set quickRehashAllSets.

Behavior compile:
'hash
    ^ self name hash'.
    
Set quickRehashAllSets.
!"
 
(0002211 - 82 - 82 - 82 - 82 - 82 - 82)
KenCausey
08-08-05 22:02

I loaded this changeset in 3.8-6665-basic without errors but did not test further.
 
(0003883 - 13 - 13 - 13 - 13 - 13 - 13)
MarcusDenker
02-16-06 17:40

added to 3.9a
 

- Issue History
Date Modified Username Field Change
08-08-05 21:53 KenCausey New Issue
08-08-05 21:53 KenCausey File Added: BehaviorHashEnh.cs.gz
08-08-05 21:54 KenCausey Note Added: 0002207
08-08-05 21:56 KenCausey Note Added: 0002208
08-08-05 21:57 KenCausey Note Added: 0002209
08-08-05 22:00 KenCausey Note Added: 0002210
08-08-05 22:02 KenCausey Note Added: 0002211
01-22-06 12:35 pmm Issue Monitored: pmm
02-16-06 17:40 MarcusDenker Status new => closed
02-16-06 17:40 MarcusDenker Note Added: 0003883
02-16-06 17:40 MarcusDenker Resolution open => fixed
02-16-06 17:40 MarcusDenker Fixed in Version  => 3.9


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
62 total queries executed.
43 unique queries executed.
Powered by Mantis Bugtracker