Hash values

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

Hash values

Alexandre Bergel-4
Hi!

Apparently in Pharo 1.1, hash values may be greater than 4096. What is the range of the hash values?

Cheers,
Alexandre

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Hash values

Henrik Sperre Johansen
  On 02.06.2010 00:15, Alexandre Bergel wrote:

> Hi!
>
> Apparently in Pharo 1.1, hash values may be greater than 4096. What is the range of the hash values?
>
> Cheers,
> Alexandre
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Hash values could always be greater than 4096 :)
Identity hashes can't, but they are scaled in 1.1, to avoid bad
clustering for objects not redefining hash.
Basically they're multiplied by 2^18, which gives the largest possible
range while still keeping all small integers.
See ProtoObject>>identityHash for details, old identityHash is now
basicIdentityHash.
Cheers,
Henry

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Hash values

Alexandre Bergel
>>
> Hash values could always be greater than 4096 :)
> Identity hashes can't, but they are scaled in 1.1, to avoid bad clustering for objects not redefining hash.
> Basically they're multiplied by 2^18, which gives the largest possible range while still keeping all small integers.
> See ProtoObject>>identityHash for details, old identityHash is now basicIdentityHash.
> Cheers,


Thanks for the update Henry!

Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Hash values

Levente Uzonyi-2
In reply to this post by Henrik Sperre Johansen
On Wed, 2 Jun 2010, Henrik Sperre Johansen wrote:

> On 02.06.2010 00:15, Alexandre Bergel wrote:
>> Hi!
>>
>> Apparently in Pharo 1.1, hash values may be greater than 4096. What is the
>> range of the hash values?
>>
>> Cheers,
>> Alexandre
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> Hash values could always be greater than 4096 :)
> Identity hashes can't, but they are scaled in 1.1, to avoid bad clustering

That's not true. You may be surprised, but the value of #identityHash
can be any SmallInteger. Just try this:
{SmallInteger minVal. SmallInteger maxVal} collect: #identityHash.

> for objects not redefining hash.
> Basically they're multiplied by 2^18, which gives the largest possible range
> while still keeping all small integers.
> See ProtoObject>>identityHash for details, old identityHash is now
> basicIdentityHash.

This may cause compatibility problems for packages which implement custom
hashes or custom hashed collections. I think Magma will be affected by
this, though I didn't check the code.


Levente

> Cheers,
> Henry
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Hash values

Henrik Sperre Johansen

On Jun 2, 2010, at 3:04 32AM, Levente Uzonyi wrote:

> On Wed, 2 Jun 2010, Henrik Sperre Johansen wrote:
>
>> On 02.06.2010 00:15, Alexandre Bergel wrote:
>>> Hi!
>>> Apparently in Pharo 1.1, hash values may be greater than 4096. What is the range of the hash values?
>>> Cheers,
>>> Alexandre
>>> _______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> Hash values could always be greater than 4096 :)
>> Identity hashes can't, but they are scaled in 1.1, to avoid bad clustering
>
> That's not true. You may be surprised, but the value of #identityHash can be any SmallInteger. Just try this:
> {SmallInteger minVal. SmallInteger maxVal} collect: #identityHash.
Yeah, forgot about that one.
>
>> for objects not redefining hash.
>> Basically they're multiplied by 2^18, which gives the largest possible range while still keeping all small integers.
>> See ProtoObject>>identityHash for details, old identityHash is now basicIdentityHash.
>
> This may cause compatibility problems for packages which implement custom hashes or custom hashed collections. I think Magma will be affected by this, though I didn't check the code.
>
>
Not sure why it ended up basicIdentity / identity instead of identity / scaledIdentity, but that's true.

Cheers,
Henry
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Hash values

Stéphane Ducasse
>>>
>>>> Hi!
>>>> Apparently in Pharo 1.1, hash values may be greater than 4096. What is the range of the hash values?
>>>> Cheers,
>>>> Alexandre
>>>> _______________________________________________
>>>> Pharo-project mailing list
>>>> [hidden email]
>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>> Hash values could always be greater than 4096 :)
>>> Identity hashes can't, but they are scaled in 1.1, to avoid bad clustering
>>
>> That's not true. You may be surprised, but the value of #identityHash can be any SmallInteger. Just try this:
>> {SmallInteger minVal. SmallInteger maxVal} collect: #identityHash.
> Yeah, forgot about that one.
>>
>>> for objects not redefining hash.
>>> Basically they're multiplied by 2^18, which gives the largest possible range while still keeping all small integers.
>>> See ProtoObject>>identityHash for details, old identityHash is now basicIdentityHash.
>>
>> This may cause compatibility problems for packages which implement custom hashes or custom hashed collections. I think Magma will be affected by this, though I didn't check the code.
>>
>>
> Not sure why it ended up basicIdentity / identity instead of identity / scaledIdentity, but that's true.

so what should we do in 1.2?

Stef
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Hash values

Andres Valloud-4
I still think leaving identityHash alone and using scaledIdentityHash to
multiply by 2^18 is better for backwards compatibility.  However, I do
not know how much of a problem changing identityHash will cause for
existing code.  Something that has always bugged me about changing
identityHash is that (as far as I've seen) identityHash is typically
assumed to answer whatever bits are in the object header.  I am not sure
introducing an exception in Pharo, or even changing the assumption that
has held for decades, is worth the benefit of changing identityHash.

On 6/2/10 0:44 , Stéphane Ducasse wrote:

>>>>          
>>>>> Hi!
>>>>> Apparently in Pharo 1.1, hash values may be greater than 4096. What is the range of the hash values?
>>>>> Cheers,
>>>>> Alexandre
>>>>> _______________________________________________
>>>>> Pharo-project mailing list
>>>>> [hidden email]
>>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>>>            
>>>> Hash values could always be greater than 4096 :)
>>>> Identity hashes can't, but they are scaled in 1.1, to avoid bad clustering
>>>>          
>>> That's not true. You may be surprised, but the value of #identityHash can be any SmallInteger. Just try this:
>>> {SmallInteger minVal. SmallInteger maxVal} collect: #identityHash.
>>>        
>> Yeah, forgot about that one.
>>      
>>>        
>>>> for objects not redefining hash.
>>>> Basically they're multiplied by 2^18, which gives the largest possible range while still keeping all small integers.
>>>> See ProtoObject>>identityHash for details, old identityHash is now basicIdentityHash.
>>>>          
>>> This may cause compatibility problems for packages which implement custom hashes or custom hashed collections. I think Magma will be affected by this, though I didn't check the code.
>>>
>>>
>>>        
>> Not sure why it ended up basicIdentity / identity instead of identity / scaledIdentity, but that's true.
>>      
> so what should we do in 1.2?
>
> Stef
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>    

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project