<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Performance problems in ConcurrentHashMap vs synchronized HashMap</title>
	<atom:link href="http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/feed/" rel="self" type="application/rss+xml" />
	<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/</link>
	<description>Things should be as simple as possible but no simpler</description>
	<lastBuildDate>Sun, 29 Nov 2009 08:53:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ismael Juma</title>
		<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/comment-page-1/#comment-171</link>
		<dc:creator>Ismael Juma</dc:creator>
		<pubDate>Mon, 29 Jun 2009 19:44:33 +0000</pubDate>
		<guid isPermaLink="false">http://gregluck.com/blog/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/#comment-171</guid>
		<description>Greg,
Yes, but ConcurrentHashMap is mostly lock-free on gets (it just locks if it finds an Entry with value null). Locks are used for puts though. And if you can at most have 8/16 concurrent threads, then 100 segments seems high. To quote from the documentation:
&quot;Ideally, you should choose a value to accommodate as many
* threads as will ever concurrently modify the table. Using a
* significantly higher value than you need can waste space and time&quot;
Note that it says &quot;concurrently modify&quot;. If you only have 8/16 cores, it&#039;s unlikely you will have 100 threads concurrently modifying the map. Anyway, the documentation also says that underestimates or overestimates within an order of magnitude are do not usually have a noticeably impact.
I will stop here as I think I have made my point by now. :)
Ismael
</description>
		<content:encoded><![CDATA[<p>Greg,<br />
Yes, but ConcurrentHashMap is mostly lock-free on gets (it just locks if it finds an Entry with value null). Locks are used for puts though. And if you can at most have 8/16 concurrent threads, then 100 segments seems high. To quote from the documentation:<br />
&#8220;Ideally, you should choose a value to accommodate as many<br />
* threads as will ever concurrently modify the table. Using a<br />
* significantly higher value than you need can waste space and time&#8221;<br />
Note that it says &#8220;concurrently modify&#8221;. If you only have 8/16 cores, it&#8217;s unlikely you will have 100 threads concurrently modifying the map. Anyway, the documentation also says that underestimates or overestimates within an order of magnitude are do not usually have a noticeably impact.<br />
I will stop here as I think I have made my point by now. <img src='http://gregluck.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Ismael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Luck</title>
		<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/comment-page-1/#comment-170</link>
		<dc:creator>Greg Luck</dc:creator>
		<pubDate>Mon, 29 Jun 2009 11:42:32 +0000</pubDate>
		<guid isPermaLink="false">http://gregluck.com/blog/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/#comment-170</guid>
		<description>Kevin
Ehcache has the Apache 2 license. Version 1.6 has NO dependencies, just JDK 1.5 and higher.
Ehcache will be the fastest implementation you can find for an in-process cache. Caches add things like eviction, expiry, listeners etc. If you really just need concurrent maps/lists/sets I would recommend java.util.concurrent. The Backport Concurrent library has quite a lot more stuff so it is also worth a look.
</description>
		<content:encoded><![CDATA[<p>Kevin<br />
Ehcache has the Apache 2 license. Version 1.6 has NO dependencies, just JDK 1.5 and higher.<br />
Ehcache will be the fastest implementation you can find for an in-process cache. Caches add things like eviction, expiry, listeners etc. If you really just need concurrent maps/lists/sets I would recommend java.util.concurrent. The Backport Concurrent library has quite a lot more stuff so it is also worth a look.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Luck</title>
		<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/comment-page-1/#comment-169</link>
		<dc:creator>Greg Luck</dc:creator>
		<pubDate>Mon, 29 Jun 2009 10:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://gregluck.com/blog/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/#comment-169</guid>
		<description>Sure.
By number of threads I am referring to the number the program is using. With synchronized,  threads queue up to get in. The time taken to get in increases as the number of threads go up.
The number of threads that can be executed _concurrently_ depends on the number of cores in the system. Our production experience is with 8 cores.
</description>
		<content:encoded><![CDATA[<p>Sure.<br />
By number of threads I am referring to the number the program is using. With synchronized,  threads queue up to get in. The time taken to get in increases as the number of threads go up.<br />
The number of threads that can be executed _concurrently_ depends on the number of cores in the system. Our production experience is with 8 cores.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/comment-page-1/#comment-168</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Sun, 28 Jun 2009 10:28:52 +0000</pubDate>
		<guid isPermaLink="false">http://gregluck.com/blog/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/#comment-168</guid>
		<description>Hi there,
I am working on an open-source project that would benefit from having the fastest map/list/set lookup times. I am basing it on at least JDK 1.5, although with 1.7 due out soon, 1.6 has been out long enough that we may require 1.6. I am curious if your library is a) allowed to be distributed with another project so that it can be built and run without requiring another download, and b) does it allow for faster lookups, sorts, even puts than the current JDK map implementation (and list/set for that matter)?
Thanks.
</description>
		<content:encoded><![CDATA[<p>Hi there,<br />
I am working on an open-source project that would benefit from having the fastest map/list/set lookup times. I am basing it on at least JDK 1.5, although with 1.7 due out soon, 1.6 has been out long enough that we may require 1.6. I am curious if your library is a) allowed to be distributed with another project so that it can be built and run without requiring another download, and b) does it allow for faster lookups, sorts, even puts than the current JDK map implementation (and list/set for that matter)?<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ismael Juma</title>
		<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/comment-page-1/#comment-167</link>
		<dc:creator>Ismael Juma</dc:creator>
		<pubDate>Sat, 27 Jun 2009 19:00:48 +0000</pubDate>
		<guid isPermaLink="false">http://gregluck.com/blog/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/#comment-167</guid>
		<description>I forgot to mention, the reason why I bring this up is that the number of segments is affected by the concurrency level and this affects the performance of things like size and iteration.
Ismael
</description>
		<content:encoded><![CDATA[<p>I forgot to mention, the reason why I bring this up is that the number of segments is affected by the concurrency level and this affects the performance of things like size and iteration.<br />
Ismael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ismael Juma</title>
		<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/comment-page-1/#comment-166</link>
		<dc:creator>Ismael Juma</dc:creator>
		<pubDate>Sat, 27 Jun 2009 18:59:08 +0000</pubDate>
		<guid isPermaLink="false">http://gregluck.com/blog/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/#comment-166</guid>
		<description>Hi Greg,
Maybe there&#039;s a terminology issue here. It&#039;s quite possible for people to use hundreds or thousands of threads. However, the concurrency level is about the number of concurrent threads and that is limited by the number of logical cores in your system.
Systems that provide hundreds or thousands of logical cores are quite rare these days (Azul aside).
Best,
Ismael
</description>
		<content:encoded><![CDATA[<p>Hi Greg,<br />
Maybe there&#8217;s a terminology issue here. It&#8217;s quite possible for people to use hundreds or thousands of threads. However, the concurrency level is about the number of concurrent threads and that is limited by the number of logical cores in your system.<br />
Systems that provide hundreds or thousands of logical cores are quite rare these days (Azul aside).<br />
Best,<br />
Ismael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Luck</title>
		<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/comment-page-1/#comment-165</link>
		<dc:creator>Greg Luck</dc:creator>
		<pubDate>Fri, 26 Jun 2009 20:54:29 +0000</pubDate>
		<guid isPermaLink="false">http://gregluck.com/blog/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/#comment-165</guid>
		<description>It is not uncommon for Ehcache caches to be hit by hundreds or in some cases thousands of concurrent threads. Having said that, access times for put and get for a range of thread levels are below 10 microseconds. I have tested up to 2000 concurrent threads with good results.
</description>
		<content:encoded><![CDATA[<p>It is not uncommon for Ehcache caches to be hit by hundreds or in some cases thousands of concurrent threads. Having said that, access times for put and get for a range of thread levels are below 10 microseconds. I have tested up to 2000 concurrent threads with good results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ismael Juma</title>
		<link>http://gregluck.com/blog/archives/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/comment-page-1/#comment-164</link>
		<dc:creator>Ismael Juma</dc:creator>
		<pubDate>Fri, 26 Jun 2009 20:13:35 +0000</pubDate>
		<guid isPermaLink="false">http://gregluck.com/blog/2009/06/performance-problems-in-concurrenthashmap-vs-synchronized-hashmap/#comment-164</guid>
		<description>Hi Greg,
How did you arrive to the number 100 for concurrency level? It seems to me that it&#039;s a bit high for the common case.
It would also be interesting to see how NonBlockingHashMap compares.
Best,
Ismael
</description>
		<content:encoded><![CDATA[<p>Hi Greg,<br />
How did you arrive to the number 100 for concurrency level? It seems to me that it&#8217;s a bit high for the common case.<br />
It would also be interesting to see how NonBlockingHashMap compares.<br />
Best,<br />
Ismael</p>
]]></content:encoded>
	</item>
</channel>
</rss>
