This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: New hash function


Tom Tromey wrote:
> +  return (jint) ((unsigned long long) obj % 0x7fffffff);

Do we have any statistics showing an improvement with this new hashcode
function?

I'm not too crazy about the 64-bit modulus operator.  I tested it on a couple of
machines I use:

CPU		Old	New
------------	---	---
PIII, 600MHz	 39	159
EV56, 533MHz	  5	 30

where "Old" and "New" are the previous and current hashcode functions,
respectively, and times are an average measured in cycles, using the rdtsc or
rpcc instructions.  Both tests were compiled with gcc -O2.

I don't see a justification for "long long" arithmetic here anyway, using simple
"(unsigned long)" avoids a function call on the PIII, and has no effect on the
EV56, or any other 64-bit CPU where sizeof(long) == sizeof(void *).

--
Jeff Sturm
jeff.sturm@appnet.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]