Oops, did you remove the excess debug statements I put in or can you point a bit to where they might be? I'm not at all sure I could recognize such places..
David Jencks On 2001.11.14 14:56:29 -0500 David Maplesden wrote: > Looks good Hiram, > > Can I make one suggestion. When I was profiling and improving JBossMQ's > performance I implemented a couple of static methods > SpyMessage.writeMessage() and SpyMessage.readMessage() to use instead of > the > standard writeObject and readObject methods. I think you should use them > here. > > They work fine, you get back exactly the same object you write out, and > they > are used by all the persistence and communication mechanisms currently > because they are many times quicker than the standard object > serialization > (which is horribly slow). > > Oh, and if we are talking about performance, I would appreciate everyone > being very careful about placing debug statements inside any code that is > executed for every message through the system. Several of these have > been > introduced with the advent of the message caching and David J's new > stuff. > > The cost of constructing all the message strings, even if they aren't > used, > can add considerable overhead to the system (if you don't believe me then > create a test and see). Remember I managed to get somewhere between a 10 > to > 20 times speed improvement by improving the serialisation code and > removing > these debug statements from inside the inner loop. If you really, really > want them then place them behind a static final boolean flag i.e. > > if(DEBUG) log.debug("a message"); > > so that we can easily set the flag to false and recompile a higher > performance version of the engine. With the static flag set to false the > compiler removes the line completely, so there is no performance hit at > all. > > Thanks David. > > > -----Original Message----- > > From: Hiram Chirino [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, November 14, 2001 5:24 PM > > To: [EMAIL PROTECTED] > > Subject: [JBoss-dev] CVS update: jbossmq/src/main/org/jboss/mq/pm/file > > CacheStore.java CacheStoreMBean.java > > > > > > User: chirino > > Date: 01/11/13 20:24:08 > > > > Added: src/main/org/jboss/mq/pm/file CacheStore.java > > CacheStoreMBean.java > > Log: > > Factored out a CacheStore object from the message store. > > This should lay the > > ground work needed so that the MessageCache can use a PM > > for saving and loading > > messages. > > > > Also fixed a small bug in the file PM. It was not properly > > restoring the message > > after a server restart. > > > > Revision Changes Path > > 1.1 > > jbossmq/src/main/org/jboss/mq/pm/file/CacheStore.java > > > > Index: CacheStore.java > > =================================================================== > > /* > > * JBoss, the OpenSource J2EE webOS > > * > > * Distributable under LGPL license. > > * See terms of license at gnu.org. > > */ > > package org.jboss.mq.pm.file; > > > > import java.io.BufferedInputStream; > > import java.io.BufferedOutputStream; > > import java.io.File; > > import java.io.FileInputStream; > > import java.io.FileOutputStream; > > import java.io.IOException; > > import java.io.ObjectInputStream; > > import java.io.ObjectOutputStream; > > > > import javax.jms.JMSException; > > import org.jboss.mq.SpyJMSException; > > import org.jboss.mq.SpyMessage; > > import org.jboss.mq.server.MessageReference; > > import org.jboss.system.ServiceMBeanSupport; > > > > /** > > * This class manages the persistence needs of the MessageCache > > * > > * @author Hiram Chirino > > * @version $Revision: 1.1 $ > > */ > > public class CacheStore extends ServiceMBeanSupport > > implements org.jboss.mq.pm.CacheStore, CacheStoreMBean { > > String dataDirectory; > > File dataFile; > > > > /** > > * @see ServiceMBeanSupport#getName() > > */ > > public String getName() { > > return "JBossMQ-CacheStore"; > > } > > > > /** > > * @see CacheStore#loadFromStorage(MessageReference) > > */ > > public SpyMessage loadFromStorage(MessageReference mh) > > throws JMSException { > > try { > > File f = new File(dataFile, "Message-" + mh.referenceId); > > ObjectInputStream is = new ObjectInputStream(new > > BufferedInputStream(new FileInputStream(f))); > > Object rc = is.readObject(); > > is.close(); > > return (SpyMessage) rc; > > } catch (ClassNotFoundException e) { > > throw new SpyJMSException("Could not load message > > from secondary storage: ", e); > > } catch (IOException e) { > > throw new SpyJMSException("Could not load message > > from secondary storage: ", e); > > } > > } > > > > /** > > * @see CacheStore#saveToStorage(MessageReference, SpyMessage) > > */ > > public void saveToStorage(MessageReference mh, > > SpyMessage message) throws JMSException { > > try { > > File f = new File(dataFile, "Message-" + mh.referenceId); > > ObjectOutputStream os = new ObjectOutputStream(new > > BufferedOutputStream(new FileOutputStream(f))); > > os.writeObject(message); > > os.close(); > > } catch (IOException e) { > > throw new SpyJMSException("Could not load message > > from secondary storage: ", e); > > } > > } > > > > /** > > * @see CacheStore#removeFromStorage(MessageReference) > > */ > > public void removeFromStorage(MessageReference mh) > > throws JMSException { > > File f = new File(dataFile, "Message-" + mh.referenceId); > > f.delete(); > > } > > > > /** > > * @see CacheStoreMBean#getDataDirectory() > > */ > > public String getDataDirectory() { > > return null; > > } > > > > /** > > * @see CacheStoreMBean#setDataDirectory(String) > > */ > > public void setDataDirectory(String newDataDirectory) { > > dataDirectory = newDataDirectory; > > } > > > > /** > > * This gets called to start the service. > > */ > > protected void startService() throws Exception { > > File jbossHome = new > > File(System.getProperty("jboss.system.home")); > > dataFile = new File(jbossHome, dataDirectory); > > log.debug("Data directory set to: " + > > dataFile.getCanonicalPath()); > > > > dataFile.mkdirs(); > > if (!dataFile.isDirectory()) > > throw new Exception("The configured data directory > > is not valid: " + dataDirectory); > > > > // Clean out the directory of any previous files. > > File files[] = dataFile.listFiles(); > > log.debug("Removing " + files.length + " file(s) > > from: " + dataFile.getCanonicalPath()); > > for (int i = 0; i < files.length; i++) { > > files[i].delete(); > > } > > > > } > > > > /** > > * @see CacheStoreMBean#getCacheStoreInstance() > > */ > > public Object getInstance() { > > return this; > > } > > > > } > > > > > > 1.1 > > jbossmq/src/main/org/jboss/mq/pm/file/CacheStoreMBean.java > > > > Index: CacheStoreMBean.java > > =================================================================== > > /* > > * JBoss, the OpenSource J2EE webOS > > * > > * Distributable under LGPL license. > > * See terms of license at gnu.org. > > */ > > package org.jboss.mq.pm.file; > > > > import org.jboss.system.ServiceMBean; > > import javax.management.ObjectName; > > > > /** > > * <description>MBean interface for the JBossMQ JMX service. > > * > > * @author Vincent Sheffer ([EMAIL PROTECTED]) > > * @see <related> > > * @version $Revision: 1.1 $ > > */ > > public interface CacheStoreMBean > > extends ServiceMBean, org.jboss.mq.pm.CacheStoreMBean > > { > > /** > > * Gets the DataDirectory attribute of the > > CacheStoreMBean object > > * > > * @return The DataDirectory value > > */ > > public java.lang.String getDataDirectory(); > > > > /** > > * Sets the DataDirectory attribute of the > > CacheStoreMBean object > > * > > * @param newDataDirectory The new DataDirectory value > > */ > > public void setDataDirectory(java.lang.String newDataDirectory); > > } > > > > > > > > > > _______________________________________________ > > Jboss-development mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/jboss-development > > > > _______________________________________________ > Jboss-development mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-development > > _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development