[jboss-user] [JBoss Microcontainer Development] New message: "Re: Profiling the dependency project"

Kabir Khan do-not-reply at jboss.com
Tue Feb 9 15:07:24 EST 2010


User development,

A new message was posted in the thread "Profiling the dependency project":

http://community.jboss.org/message/525220#525220

Author  : Kabir Khan
Profile : http://community.jboss.org/people/kabir.khan@jboss.com

Message:
--------------------------------------------------------------
> mailto:kabir.khan at jboss.com wrote:
>  
> We do quite a lot of adding to and removing from AbstractController.installed and the sets stored in AbstractController.contextsByState. They are currently implemented as CopyOnWriteArraySets which perform badly when there are large numbers of entries in the sets already. I tried replacing these with ConcurrentSet (based on ConcurrentHashMap), but that performed worse. I've spoken to Jason who gave me a few ideas, but will put those off until I've picked off a few other things.
What I forgot to mention here is that the perfomance of these sets is related to the size. COWAS performs better than ConcurrentSet when a small number of exisiting entries are present, which probably makes it ok for the 'installing' set since that will not contain that many entries. It does however degrade its performance rapidly when there are many entries there, so it is probably not the best choice for the sets stored in 'contextsByState'.
 
This little test demonstrates the difference:
public class SetBenchmark
{
   static int prefill = 1000;
   
   static int iterations = 10000000;
   
   public static void main(String[] args)
   {
      Set<String> set = new CopyOnWriteArraySet<String>();
//      Set<String> set = new ConcurrentSet();
//      Set<String> set = new HashSet<String>();
//      Set<String> set = new ConcurrentSkipListSet<String>();
      
      for (int i = 0 ; i < prefill ; i++)
      {
         set.add("XYZ" + i);
      }
      
      long start = System.currentTimeMillis();
      for (int i = 0 ; i < iterations ; i++)
      {
         set.add("XXX" + i);
         set.remove("XXX" + i);
      }
      System.out.println("-----> " + (System.currentTimeMillis() - start));
   }
}
 

 
The times in ms for various amounts of prefill, COWAS, normal HashSet, ConcurrentSkipListSet and ConcurrentSet:
> prefill 0
> ------------
> COWAS: 4648 4397 4618 4430 4460
> CS: 5141 5026 5177 4908 5139
> HS: 4267 3954 3762 4070 3952
> CSLS: 5475 5504 5461 5649 5406
>  
> prefill 10
> ----------
> COWAS: 6781 7026 6502 6505
> CS: 5009 4954 4791 5168
> HS: 4165 4403 4206
> CSLS: 6046 6291 6216
>  
> prefill 100
> -----------
> COWAS: 29138 31600
> CS: 5115 5208 5179 5511
> HS: 4378 4525 4098 4181
> CSLS: 6836 7029 6721
>  
> prefill 1000
> ------------
> COWAS: About 5 minutes
> CS: 5030 5212
> CSLS: 8488 7627 7797
> HS: 4141 4085
 
So this might explain why CS makes performance worse when used for contextsByState's sets, in my benchmark most states will have very few entries and only a few willl have lots of entries. CSLS always seems to be slower than CS so we won't go with that.
 
A few of Jason's suggestions were;
- Create own COWAS implementation based on FastCopyHashMap
- Try a normal synchronized HashSet (need to make sure first that the way we use it we don't iterate over the entries)
- ConcurrentSkipListMap although its performance degrades with performance (evaluated above)

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/525220#525220




More information about the jboss-user mailing list