List Info

Thread: - Re: Optimisations: A couple of




- Re: Optimisations: A couple of
country flaguser name
United States
2008-05-14 10:33:18
"timfox" wrote : There are a couple of areas for
valuable optimisation if anyone would like to take them:
  | 
  | 1)
  | 
  | One is that generating JMS message ids before sending
can slow things down significantly (maybe 5%??).
  | 
  | I noticed that if i set
producer.setDisableMessageID(true) on the producer before
sending performance increases significantly
  | 
  | I am sending 1k non persistent bytes messages from
client one my laptop to server on another machine with
gigabit lan and i can get about 45K msgs / sec , but this
drops to about 40K or less with disablemessageid set to
false
  | 
  | I suspect this is due to the following in
JBossMessageProducer:
  | 
  |   | String id = UUID.randomUUID().toString();
  |   | bm.setJMSMessageID("ID:" + id);
  |   | 
  | 
  | which involves generation and two (?) string copies.
  | 

It seems the bottleneck is the generation of the UUID.

When using UUID.randomUUID(), the implementation uses a
SecureRandom.
If I use Random instead and creates the UUID with new
UUID(rand.nextLong(), nextLong(), the perf increases
significantely.

I've isolated this in the following tests:


  |    public void testRandomUUID() throws Exception
  |    {
  |       long start = System.currentTimeMillis();
  |       
  |       for (int i = 0; i < MANY_TIMES; i++)
  |       {
  |          UUID uuid = UUID.randomUUID();
  |          String id = "ID:" + uuid;
  |       }
  |       
  |       long duration = System.currentTimeMillis() -
start;
  |       System.out.println(getName() + ": " +
duration);      
  |    }
  |    
  |    public void testSecureRandom() throws Exception
  |    {
  |       doManyRandomLongs(new SecureRandom());
  |    }
  | 
  |    public void testRandom() throws Exception
  |    {
  |       doManyRandomLongs(new Random());
  |    }
  | 
  |    public void doManyRandomLongs(Random rand) {
  |       long start = System.currentTimeMillis();
  |       
  |       for (int i = 0; i < MANY_TIMES; i++)
  |       {
  |          UUID uuid = new UUID(rand.nextLong(),
rand.nextLong());
  |          String id = "ID:" + uuid;
  |       }
  |       
  |       long duration = System.currentTimeMillis() -
start;
  |       System.out.println(getName() + ": " +
duration);
  |    }
  | 

When running the loop 1 million times, I've got:
testRandomUUID: 18625
testSecureRandom: 19430
testRandom: 5059

=> using Random.nextLong instead of RandomUUID, we go
from 18s to 5s



View the original post : http://www.jboss.com/index.html?
module=bb&op=viewtopic&p=4150792#4150792

Reply to the post : http://www.jboss.com/index.
html?module=bb&op=posting&mode=reply&p=4150792
_______________________________________________
jboss-dev-forums mailing list
jboss-dev-forumslists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-dev-foru
ms

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )