commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: [COLLECTIONS] FastHashMap performance
Date Wed, 04 Jun 2003 12:46:46 GMT

Howdy,
Thanks for letting me know of the -Xint switch: I had missed it before.

I've run the benchmark with -Xint, and the results are indeed different.
Now the FastHashMap inserts are slightly slower than HashMap and
Collections.synchronizedMap(new HashMap()) as expected.  So clearly the
interpreter (at least for my JVM on my Solaris box) is doing a great job
optimizing the FastHashMap class at runtime.  The performance is about
4x worse with -Xint.

So what lesson should I take from this?  The interpreter plays a large
role, OK I accept that.  In real life production systems we never use
-Xint, so should I disregard this benchmark as it applies to production
systems?  It seems like without -Xint, FastHashMap is significantly
faster than the java.util.HashMap and its synchronized wrapper version
from Collections.

By the way, it seems Collections.synchronizedMap(new FastHashMap())
throws a ClassCastException during get operations.  Very strange, but I
haven't investigated further.

Anyways, thanks everyone for your help.  

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Juozas Baliuka [mailto:baliuka@centras.lt]
>Sent: Wednesday, June 04, 2003 1:46 AM
>To: Jakarta Commons Developers List
>Subject: Re: [COLLECTIONS] FastHashMap performance
>
>-Xint dissable JIT on SUN's JVM, but I can not find options to dissable
GC.
>----- Original Message -----
>From: "Shapira, Yoav" <Yoav.Shapira@mpi.com>
>To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
>Sent: Tuesday, June 03, 2003 9:52 PM
>Subject: RE: [COLLECTIONS] FastHashMap performance
>
>
>
>Howdy,
>Assuming I agree that GC and JIT play a role in my benchmark (which I
>don't without further convincing), how should I disable them?
>
>I see -XX:-DisableExplicitGC is a VM option, but it only disables
>explicit System.gc() calls, which I don't use anyways.  I couldn't find
>an option to disable JIT.
>
>The heap has ample space to hold the objects in my benchmark.  My
>results don't change if I increase -Xmx or change -Xms to match -Xmx.
>
>Yoav Shapira
>Millennium ChemInformatics
>
>
>>-----Original Message-----
>>From: Juozas Baliuka [mailto:baliuka@centras.lt]
>>Sent: Tuesday, June 03, 2003 3:37 PM
>>To: Jakarta Commons Developers List
>>Subject: Re: [COLLECTIONS] FastHashMap performance
>>
>>
>>I have tried to implement performance tests for maps, but it is not
>>trivial.
>>Try to dissable GC and JIT for performance tests.
>>
>>----- Original Message -----
>>From: "Shapira, Yoav" <Yoav.Shapira@mpi.com>
>>To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
>>Sent: Tuesday, June 03, 2003 9:05 PM
>>Subject: RE: [COLLECTIONS] FastHashMap performance
>>
>>
>>
>>Howdy,
>>I've had tests with both a normal hashmap (just new HashMap() used)
and
>>a synchronized wrapper (Collections.synchronizedMap(new HashMap()).  I
>>would expect the normal HashMap to be faster than both the FastHashMap
>>and the synchronized HashMap.  Is my expectation wrong?
>>
>>However, here are the results:
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 1592 / Read time: 30]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1265 / Read time: 6]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>983 / Read time: 7]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 1158 / Read time: 2]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1194 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>827 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 990 / Read time: 2]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1006 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>732 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 949 / Read time: 3]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1003 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>1579 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 888 / Read time: 2]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1045 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>793 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 1151 / Read time: 2]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>855 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>905 / Read time: 3]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 1217 / Read time: 1]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1269 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>1107 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 1062 / Read time: 2]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1252 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>971 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 1460 / Read time: 2]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1404 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>1110 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: false / Insert
>>time: 1278 / Read time: 2]
>>[MapTest: FastHashMap: true / Synchronized wrapper: false / Insert
>time:
>>1193 / Read time: 2]
>>[MapTest: FastHashMap: false / Synchronized wrapper: true / Insert
>time:
>>1096 / Read time: 2]
>>
>>Yoav Shapira
>>Millennium ChemInformatics
>>
>>
>>>-----Original Message-----
>>>From: ericpabst@discoverfinancial.com
>>>[mailto:ericpabst@discoverfinancial.com]
>>>Sent: Tuesday, June 03, 2003 2:58 PM
>>>To: Jakarta Commons Developers List
>>>Subject: RE: [COLLECTIONS] FastHashMap performance
>>>
>>>
>>>In your test, are you synchronizing the HashMap?  FastHashMap
>>implements
>>>smart synchronization.  It should not be compared with an
>>unsynchronized
>>>version of HashMap.
>>>
>>>P.S.  In fact, it might be nice to allow doing this smart
>>synchronization
>>>on *any* Map.  i.e. alternative to Collections.synchronizeMap(Map).
>>>
>>>Eric Pabst
>>>Discover Financial Services
>>>2500 Lake Park Blvd., 3N
>>>West Valley City, UT 84120
>>>Ph: 801.902.4636
>>>Fax: 801.902.4123
>>>
>>>
>>>
>>>|---------+--------------------------->
>>>|         |           "Shapira, Yoav" |
>>>|         |           <Yoav.Shapira@mp|
>>>|         |           i.com>          |
>>>|         |                           |
>>>|         |           06/03/03 12:54  |
>>>|         |           PM              |
>>>|         |           Please respond  |
>>>|         |           to "Jakarta     |
>>>|         |           Commons         |
>>>|         |           Developers List"|
>>>|         |                           |
>>>|---------+--------------------------->
>>>
>>>---------------------------------------------------------------------
-
>-
>>-
>>>---------------------------------------|
>>>  |
>>>|
>>>  |        To:      "Jakarta Commons Developers List" <commons-
>>>dev@jakarta.apache.org>                            |
>>>  |        cc:
>>>|
>>>  |        Subject: RE: [COLLECTIONS] FastHashMap performance
>>>|
>>>
>>>---------------------------------------------------------------------
-
>-
>>-
>>>---------------------------------------|
>>>
>>>
>>>
>>>
>>>
>>>Howdy,
>>>I understand it's just a wrapper, and that the
>>>reading cannot be any faster.  I'm curious why the
>>>writing is so much faster, even in the default (not fast)
>>>mode of FastHashMap.
>>>
>>>Yoav Shapira
>>>Millennium ChemInformatics
>>>
>>>
>>>>-----Original Message-----
>>>>From: Juozas Baliuka [mailto:baliuka@centras.lt]
>>>>Sent: Tuesday, June 03, 2003 2:36 PM
>>>>To: Jakarta Commons Developers List
>>>>Subject: Re: [COLLECTIONS] FastHashMap performance
>>>>
>>>>FastHashMap can not be faster than HasMap in single thread just
>>because
>>>it
>>>>uses HasMap to implement mappings:
>>>>
>>>> public Object get(Object key) {
>>>>        if (fast) {
>>>>            return (map.get(key));
>>>>        } else {
>>>>            synchronized (map) {
>>>>                return (map.get(key));
>>>>            }
>>>>        }
>>>>    }
>>>>
>>>>
>>>>/**
>>>>     * Construct an empty map.
>>>>     */
>>>>    public FastHashMap() {
>>>>        super();
>>>>        this.map = new HashMap();
>>>>    }
>>>>
>>>>----- Original Message -----
>>>>From: "Shapira, Yoav" <Yoav.Shapira@mpi.com>
>>>>To: "Jakarta Commons Developers List"
><commons-dev@jakarta.apache.org>
>>>>Sent: Tuesday, June 03, 2003 8:00 PM
>>>>Subject: RE: [COLLECTIONS] FastHashMap performance
>>>>
>>>>
>>>>Howdy,
>>>>Neither did I, but I just ran the attached benchmark and got
>>surprising
>>>>results.  I hope the attachement comes through OK: if not I'll
>re-post
>>>>inline.  This benchmark has just one thread writing, one thread
>>>reading,
>>>>which I expected to be the case where FastHashMap is not as
efficient
>>>as
>>>>HashMap.
>>>>
>>>>The benchmark inserts 100000 records in the map, then reads 1000 of
>>>>those at random.  I run this 10 times for each map implemention.
I'm
>>>>ignoring the first run read times as there's overhead in
initializing
>>>>the Random generator.
>>>>
>>>>I'm running this test on JDK 1.4.1, no special java switches, just
>>java
>>>>MapTest on the command line, on Solaris 8.
>>>>
>>>>I'm very curious to hear comments, ideas.  I was expecting to have
to
>>>>write another test with multiple writing threads, but if FastHashMap
>>is
>>>>faster even for the simple case, why ever use the regular HashMap?
>>>>
>>>>The results are:
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 1616 / Read
>>time:
>>>>30]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 1252 / Read time: 6]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 958 / Read
>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 1203 / Read time: 2]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 820 / Read
>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 988 / Read time: 2]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 781 / Read
>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 1033 / Read time: 3]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 720 / Read
>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 1067 / Read time: 2]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 1454 / Read
>>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 1267 / Read time: 2]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 1534 / Read
>>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 862 / Read time: 2]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 1433 / Read
>>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 844 / Read time: 2]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 1578 / Read
>>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 1488 / Read time: 2]
>>>>[MapTest: Map class: java.util.HashMap / Insert time: 1450 / Read
>>time:
>>>>2]
>>>>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
>>>Insert
>>>>time: 859 / Read time: 2]
>>>>
>>>>Yoav Shapira
>>>>Millennium ChemInformatics
>>>>
>>>>
>>>>>-----Original Message-----
>>>>>From: Juozas Baliuka [mailto:baliuka@centras.lt]
>>>>>Sent: Tuesday, June 03, 2003 1:53 PM
>>>>>To: Jakarta Commons Developers List
>>>>>Subject: Re: [COLLECTIONS] FastHashMap performance
>>>>>
>>>>>I do not think it is faster than java.util.HashMap, it is just
>pseudo
>>>>>thread
>>>>>safe wrapper.
>>>>>
>>>>>----- Original Message -----
>>>>>From: "Shapira, Yoav" <Yoav.Shapira@mpi.com>
>>>>>To: <commons-dev@jakarta.apache.org>
>>>>>Sent: Tuesday, June 03, 2003 7:17 PM
>>>>>Subject: [COLLECTIONS] FastHashMap performance
>>>>>
>>>>>
>>>>>
>>>>>Howdy,
>>>>>Has anyone benchmarked the performance of the FastHashMap and how
it
>>>>>compares to the java.util.HashMap implementation?  If so, are the
>>>>>benchmarks available online somewhere?
>>>>>
>>>>>I don't doubt its quality nor its performance, just curious...
>>Thanks,
>>>>>
>>>>>Yoav Shapira
>>>>>Millennium ChemInformatics
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>This e-mail, including any attachments, is a confidential business
>>>>>communication, and may contain information that is confidential,
>>>>>proprietary
>>>>>and/or privileged.  This e-mail is intended only for the
>>individual(s)
>>>>to
>>>>>whom it is addressed, and may not be saved, copied, printed,
>>disclosed
>>>>or
>>>>>used by anyone else.  If you are not the(an) intended recipient,
>>>please
>>>>>immediately delete this e-mail from your computer system and notify
>>>the
>>>>>sender.  Thank you.
>>>>>
>>>>>
>>>>>-------------------------------------------------------------------
-
>-
>>>>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail:
commons-dev-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>-------------------------------------------------------------------
-
>-
>>>>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail:
commons-dev-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>This e-mail, including any attachments, is a confidential business
>>>>communication, and may contain information that is confidential,
>>>>proprietary
>>>>and/or privileged.  This e-mail is intended only for the
>individual(s)
>>>to
>>>>whom it is addressed, and may not be saved, copied, printed,
>disclosed
>>>or
>>>>used by anyone else.  If you are not the(an) intended recipient,
>>please
>>>>immediately delete this e-mail from your computer system and notify
>>the
>>>>sender.  Thank you.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>--------------------------------------------------------------------
-
>-
>>-
>>>----
>>>>-
>>>>----
>>>>
>>>>
>>>>>
>>---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>>>> For additional commands, e-mail:
>commons-dev-help@jakarta.apache.org
>>>>
>>>>
>>>>--------------------------------------------------------------------
-
>>>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>This e-mail, including any attachments, is a confidential business
>>>communication, and may contain information that is confidential,
>>>proprietary and/or privileged.  This e-mail is intended only for the
>>>individual(s) to whom it is addressed, and may not be saved, copied,
>>>printed, disclosed or used by anyone else.  If you are not the(an)
>>intended
>>>recipient, please immediately delete this e-mail from your computer
>>system
>>>and notify the sender.  Thank you.
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
>>
>>
>>This e-mail, including any attachments, is a confidential business
>>communication, and may contain information that is confidential,
>>proprietary
>>and/or privileged.  This e-mail is intended only for the individual(s)
>to
>>whom it is addressed, and may not be saved, copied, printed, disclosed
>or
>>used by anyone else.  If you are not the(an) intended recipient,
please
>>immediately delete this e-mail from your computer system and notify
the
>>sender.  Thank you.
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
>
>This e-mail, including any attachments, is a confidential business
>communication, and may contain information that is confidential,
>proprietary
>and/or privileged.  This e-mail is intended only for the individual(s)
to
>whom it is addressed, and may not be saved, copied, printed, disclosed
or
>used by anyone else.  If you are not the(an) intended recipient, please
>immediately delete this e-mail from your computer system and notify the
>sender.  Thank you.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org




This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message