0 Replies Latest reply: Oct 15, 2007 4:41 AM by Fredrik Johansson RSS

Multithreading

Fredrik Johansson Newbie

Hi.

We are currently using jboss serialization for a multithreaded server solution. I just ran some performance tests and saw that all my worker-threads were busy and when generating a stacktrace they all are in the same jboss serialization method.

The stacktraces look like:

"Table-GameEventDaemon-gam1-23" prio=1 tid=0x8a331500 nid=0x2ac0 runnable [0x8662e000..0x8662efa0]
 at org.jboss.serial.classmetamodel.ClassMetamodelFactory$CacheLoaderReference.setCurrentClassLoader(ClassMetamodelFactory.java:92)
 at org.jboss.serial.classmetamodel.ClassMetamodelFactory.getLoaderMap(ClassMetamodelFactory.java:248)
 at org.jboss.serial.classmetamodel.ClassMetamodelFactory.getClassMetaData(ClassMetamodelFactory.java:346)
 at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:172)
 at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
 at org.jboss.serial.persister.ObjectOutputStreamProxy.writeObjectOverride(ObjectOutputStreamProxy.java:60)
 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:298)
 at java.util.TreeMap.writeObject(TreeMap.java:1475)
 at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithMethod(RegularObjectPersister.java:120)
 at org.jboss.serial.persister.RegularObjectPersister.defaultWrite(RegularObjectPersister.java:86)
 at org.jboss.serial.persister.RegularObjectPersister.writeData(RegularObjectPersister.java:62)
 at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(ObjectDescriptorFactory.java:276)
 at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(DataContainer.java:206)
 at org.jboss.serial.io.JBossObjectOutputStream.writeObjectOverride(JBossObjectOutputStream.java:181)
 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:298)
 at com.game.util.Serializer.serialize(Serializer.java:29)


The code used to serialize the objects is written like:

public final static byte[] serialize(Object o) throws IOException {
 ByteArrayOutputStream ba = new ByteArrayOutputStream();
 BufferedOutputStream bo = new BufferedOutputStream(ba);
 JBossObjectOutputStream out = new JBossObjectOutputStream(bo);
 out.writeObject(o);
 out.flush();
 return ba.toByteArray();
 }


So, why are all threads choking at setCurrentClassloader? Is that an expensive operation?

Also, is there any way we can improve the throughput here, either by rewriting the serialize(...) method or by pooling some resources?