harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiao-Feng Li" <xiaofeng...@gmail.com>
Subject Re: [classlib] Some further study on hashcode and HashMap
Date Wed, 04 Jul 2007 13:02:35 GMT
On 7/4/07, Tim Ellison <t.p.ellison@gmail.com> wrote:
> Xiao-Feng Li wrote:
>
> <big snip>
> I just wanted to pick up on this...
>
> > (Note if we use a formula for hashing, it will be computed every time
> > it's accessed, we need consider the overhead of the computation.
>
> Not each time it is accessed, just when it is first stored, right?

Tim, This is one of the design decisions made for DRLVM hashcode
implementation. Based on a common assumption that hashcode is not
frequently accessed (only a small ratio of objects are accessed for
hashcode, and only small ratio of applications use hashcode),  we
usually don't want a constant storage for hashcode. Instead, we only
allocate the extra storage when the hashcode is accessed AND the
object is moved; Otherwise, we directly return the object address for
hashcode. Since most objects die before they are moved in a collection
(this is another common assumption we make for objects life spans),
most hashcodes will be accessed before they are stored.

So in this design of hashcode, we have some assumptions and make perf
optimizations based on them. It's unclear if the design is the best in
general, since common workloads don't have extensive hashcode
accesses, hence cannot really exhibit the design differences. (Btw,
Dacapo has some apps using hashcode heavily. )

Thanks,
xiaofeng

> Regards,
> Tim
>
>


-- 
http://xiao-feng.blogspot.com

Mime
View raw message