2007/6/29, Tim Ellison <[EMAIL PROTECTED]>:
Jimmy,Jing Lv wrote:
> 2007/6/29, Sergey Kuksenko <[EMAIL PROTECTED]>:
>> The first solution has one advantage - it can be done only in
>> classlib. The second variant should be implemented in all VMs which
>> are based on Harmony's classlib. But this way has other advantages
>> - Well-formed IdentityHashCode will helps not only for HashMap, but
>> for Hashtable, IdentityHashMap and moreover for all hashing
>> implemented by users.
>
> Ah, I never think of it, so you mean IdentityHashCode can be
> implemented in vm?

It always will be in Harmony, since it is obtained by
System#identityHashCode(Object), which is in the kernel class set.

> Doesn't vm return directly the address as the
> IdentityHashCode?(it is easiest and fastest way)

It is typical for the implementation to return the object address at the
point was first asked for it's identityHashCode, but that is not
required by the spec.


Interesting, got it :)

>> In the second variant we don't add rehashing function into HashMap. It is
>> common practice when advanced Java developers tune their HashCode
>> functions.
>> If we add rehashing function into HashMap we may break their tuning,
>> without
>> knowledge of internal rehashing functions it is impossible to tune
>> HashCode
>> function.
>> From my opinion we should think about the last argument against adding
>> rehashing into HashMap and move rehashing into VM.
>>
>
> Yes, the improved identityHashCode may help, but usually users also
> define their own hashcode, then the identityHashCode may not help,
> while rehash in classlib still works, that's why I guess improvement
> in classlib is better :)

Since the developer is defining the hashCode() I don't see how you would
know the best way to improve their value?  I think we just rely on them
to do their job properly or suffer the consequences :-)


I think we never try to make an improvement for all hashcode :) I
think we can only make a hypothesis that programmer can define a
hashcode that is distributed randomly, in that way we can rehash it
into buckets and in this hypothesis we can improve our Hash-relasted
classes.

After all, Harmony is open-source and everyone can modify the code
into his own style or for special use/performance improvement (it is
really coooool! :) ). Our discuss here may help them on tuning
HashMap. And we harmony guys just try to find a more typical way ;)

Regards,
Tim



--

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

Reply via email to