[jboss-jira] [JBoss JIRA] Commented: (JBMESSAGING-777) Revise creation of Object*Stream on Remoting/our Marshallers

Tim Fox (JIRA) jira-events at jboss.com
Tue Feb 6 19:04:20 EST 2007


    [ http://jira.jboss.com/jira/browse/JBMESSAGING-777?page=comments#action_12352498 ] 
            
Tim Fox commented on JBMESSAGING-777:
-------------------------------------

I have created a simple test to compare the performance of creating a new ObjectInput/OutputStream each time compared with re-using them:

public void test2() throws Exception
   {
      {
         long start = System.currentTimeMillis();
         
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         
         for (int i = 0; i < 100000; i++)
         {
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            
            SimpleObj obj = new SimpleObj(true);
            
            oos.writeObject(obj);
            
            oos.close();
         }
            
         byte[] bytes = baos.toByteArray();
            
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         
         for (int i = 0; i < 100000; i++)
         {            
            ObjectInputStream ois = new ObjectInputStream(bais);
            
            SimpleObj obj2 = (SimpleObj)ois.readObject();
            
            //log.info("obj2 is " + obj2);
            
            ois.close();
            
            //log.info("did " + i);
         }
         
         long end = System.currentTimeMillis();
         
         log.info("that took " + (end - start) + " ms");
      }
      
      
      {
         long start = System.currentTimeMillis();
         
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         
         ObjectOutputStream oos = new ObjectOutputStream(baos);
         
         
         for (int i = 0; i < 100000; i++)
         {            
            SimpleObj obj = new SimpleObj(true);
            
            oos.writeObject(obj);
            
            oos.flush();
         }
            
         byte[] bytes = baos.toByteArray();
            
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         
         ObjectInputStream ois = new ObjectInputStream(bais);
         
         for (int i = 0; i < 100000; i++)
         {            
                        
            SimpleObj obj2 = (SimpleObj)ois.readObject();
            
            //log.info("obj2 is " + obj2);
                                    
            //log.info("did " + i);
         }
         
         ois.close();
         
         long end = System.currentTimeMillis();
         
         log.info("that took " + (end - start) + " ms");
      }
      
      
   }

000, pageSize=2000, downCacheSize=2000
@main 23:57:48,250 INFO  [SimpleTest] that took 11391 ms
@main 23:57:56,187 INFO  [SimpleTest] that took 7937 ms

So there is about a 40% difference.

Considering that serialization is only used for object message bodies, and remoting internal invocations I don't see this is a big issue.



> Revise creation of Object*Stream on Remoting/our Marshallers
> ------------------------------------------------------------
>
>                 Key: JBMESSAGING-777
>                 URL: http://jira.jboss.com/jira/browse/JBMESSAGING-777
>             Project: JBoss Messaging
>          Issue Type: Bug
>    Affects Versions: 1.2.0.Beta2
>            Reporter: Clebert Suconic
>         Assigned To: Ovidiu Feodorov
>             Fix For: 1.2.0.CR1
>
>
> We have requested to create a new Object*Stream on every request... delegating the Object*Stream creation to the marshaller.
> A Object*Stream should be reused.. and created only once...  Especially if using JavaSerialization, since :
> I - its creation is considered expensive
> II - Object*Stream has a weird internal buffer. overusing that stream creationg might cause intermitent errors IMO. It would be better if we could avoid recreating the streaming every time.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list