james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabor Kincses <npure2...@yahoo.com>
Subject Re: Disabling the spool in James 2.2.0?
Date Fri, 14 Jan 2005 00:06:05 GMT
After replacing the one-byte at a time copy with 1k,
4k and 4k+commons-io's ByteArrayOutputStream, the
performance rose to ~7300 messages/min.  The various
settings didn't make much difference, not too
surprisignly since the test messages are 10.9kB a
piece.

Time to profile.

Hope this helps,
Gabor

--- Gabor Kincses <npure2001@yahoo.com> wrote:

> Ok.  Attached is the new version using a byte[] to
> store the mime message.  The other change is in
> MailImpl.java to instantiate the new class. 
> Performance went from ~5500 10.9kB messages/min to
> ~6800 messages/min.
> 
> --- Gabor Kincses <npure2001@yahoo.com> wrote:
> 
> > Why?  Is it the synchronization overhead?
> > 
> > Which one should I use?  I'm not finding anything
> > other than the java.io.
> > 
> > Thanks,
> > Gabor
> > 
> > --- Serge Knystautas <sergek@lokitech.com> wrote:
> > 
> > > Gabor Kincses wrote:
> > > > Ok, I found it.  MimeMessageInputStreamSource
> > > should
> > > > really be called
> > MimeMessageFileInputStreamSource,
> > > > then a MimeMessageByteArrayInputStreamSource
> > could
> > > be
> > > > written, which stores the freshly parsed out
> > > message
> > > > in  a static hash of ByteArrayInputStreams
> > instead
> > > of
> > > > temp files.  The dispose method would remove
> the
> > > entry
> > > > from the hash.
> > > 
> > > Sounds good, though I'd recommend using commons
> > io's
> > > 
> > > bytearrayoutputstream instead of the one with
> the
> > > JDK.
> > > 
> > > -- 
> > > Serge Knystautas
> > > Lokitech >> software . strategy . design >>
> > > http://www.lokitech.com
> > > p. 301.656.5501
> > > e. sergek@lokitech.com
> > > 
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > server-dev-unsubscribe@james.apache.org
> > > For additional commands, e-mail:
> > > server-dev-help@james.apache.org
> > > 
> > > 
> > 
> > 
> > =====
> > Gabor Kincses
> > Running Mandrake Linux 10.0
> > 
> > 
> > 		
> > __________________________________ 
> > Do you Yahoo!? 
> > Yahoo! Mail - now with 250MB free storage. Learn
> > more.
> > http://info.mail.yahoo.com/mail_250
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > server-dev-unsubscribe@james.apache.org
> > For additional commands, e-mail:
> > server-dev-help@james.apache.org
> > 
> > 
> 
> =====
> Gabor Kincses
> Running Mandrake Linux 10.0
> 
> 
> 	
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Mail - You care about security. So do we. 
> http://promotions.yahoo.com/new_mail>
/***********************************************************************
>  * Copyright (c) 2000-2004 The Apache Software
> Foundation.             *
>  * All rights reserved.                             
>                   *
>  *
>
-------------------------------------------------------------------
> *
>  * Licensed under the Apache License, Version 2.0
> (the "License"); you *
>  * may not use this file except in compliance with
> the License. You    *
>  * may obtain a copy of the License at:             
>                   *
>  *                                                  
>                   *
>  *     http://www.apache.org/licenses/LICENSE-2.0   
>                   *
>  *                                                  
>                   *
>  * Unless required by applicable law or agreed to in
> writing, software *
>  * distributed under the License is distributed on
> an "AS IS" BASIS,   *
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
> either express or     *
>  * implied.  See the License for the specific
> language governing       *
>  * permissions and limitations under the License.   
>                   *
> 
>
***********************************************************************/
> 
> package org.apache.james.core;
> 
> import java.io.*;
> 
> import javax.mail.MessagingException;
> 
> import
> org.apache.avalon.framework.activity.Disposable;
> 
> /**
>  * Takes an input stream and creates a repeatable
> input stream source
>  * for a MimeMessageWrapper.  It does this by
> completely reading the
>  * input stream and saving that to a temporary file
> that should delete on exit,
>  * or when this object is GC'd.
>  *
>  * @see MimeMessageWrapper
>  *
>  *
>  */
> public class MimeMessageByteArrayInputStreamSource
>     extends MimeMessageSource
>     implements Disposable {
>     
>     /**
>      * Random key into the cache
>      */
>     String sourceId = null;
> 
>     /**
>      * The mime bytes
>      */
>     byte[] bytes = null;
>     
>     /**
>      * @param key
>      * @param in
>      * @throws MessagingException
>      */
>     /**
>      * Construct a new
> MimeMessageByteArrayInputStreamSource from an
>      * <code>InputStream</code> that contains the
> bytes of a
>      * MimeMessage.
>      *
>      * @param key the prefix for the name of the
> temp file
>      * @param in the stream containing the
> MimeMessage
>      *
>      * @throws MessagingException if an error occurs
> while trying to store
>      *                            the stream
>      */
>     public
> MimeMessageByteArrayInputStreamSource(String key,
> InputStream in)
>             throws MessagingException {
>         //We want to immediately read this into a
> byte array
>         //Create a byte array and channel the input
> stream into it
>         OutputStream out = null;
>         ByteArrayOutputStream bout = null;
>         try {
>             out = new BufferedOutputStream(bout =
> new ByteArrayOutputStream());
>             int b = -1;
>             while ((b = in.read()) != -1) {
>                 out.write(b);
>             }
>             out.flush();
>             sourceId = key;
>             bytes =  bout.toByteArray();
>         } catch (IOException ioe) {
>             throw new MessagingException("Unable to
> retrieve the data: " + ioe.getMessage(), ioe);
>         } finally {
>             try {
>                 if (out != null) {
>                     out.close();
>                 }
>             } catch (IOException ioe) {
>                 // Ignored - logging unavailable to
> log this non-fatal error.
>             }
> 
>             try {
>                 if (in != null) {
>                     in.close();
>                 }
>             } catch (IOException ioe) {
>                 // Ignored - logging unavailable to
> log this non-fatal error.
>             }
>         }
>     }
> 
>     /**
>      * Returns the unique identifier of this input
> stream source
>      *
>      * @return the unique identifier for this
> MimeMessageByteArrayInputStreamSource
>      */
>     public String getSourceId() {
>         return sourceId;
>     }
> 
>     /**
>      * Get an input stream to retrieve the data
> stored in the temporary file
>      *
>      * @return a <code>BufferedInputStream</code>
> containing the data
>      */
>     public synchronized InputStream getInputStream()
> throws IOException {
>         return new BufferedInputStream(new
> ByteArrayInputStream(bytes));
>     }
> 
>     /**
>      * Get the size of the temp file
>      *
>      * @return the size of the temp file
>      *
>      * @throws IOException if an error is encoutered
> while computing the size of the message
>      */
>     public long getMessageSize() throws IOException
> {
>         return bytes.length;
>     }
> 
>     /**
>      * @see
>
org.apache.avalon.framework.activity.Disposable#dispose()
>      */
>     public void dispose() {
>         bytes = null;
>     }
> 
>     /**
>      * <p>Finalizer that closes and deletes the temp
> file.  Very bad.</p>
>      * We're leaving this in temporarily, while also
> establishing a more
>      * formal mechanism for cleanup through use of
> the dispose() method.
>      *
>      */
>     public void finalize() {
>         dispose();
>     }
> }
> 
> >
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail:
server-dev-help@james.apache.org


=====
Gabor Kincses
Running Mandrake Linux 10.0


	
		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message