[ 
https://issues.apache.org/jira/browse/JAMES-2343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16452647#comment-16452647
 ] 

ASF GitHub Bot commented on JAMES-2343:
---------------------------------------

Github user chikei commented on a diff in the pull request:

    https://github.com/apache/james-project/pull/105#discussion_r184136322
  
    --- Diff: 
server/container/core/src/main/java/org/apache/james/server/core/BufferedDeferredFileOutputStream.java
 ---
    @@ -0,0 +1,278 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You 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.server.core;
    +
    +import org.apache.commons.io.IOUtils;
    +import org.apache.commons.io.output.ByteArrayOutputStream;
    +import org.apache.commons.io.output.DeferredFileOutputStream;
    +import org.apache.commons.io.output.ThresholdingOutputStream;
    +
    +import java.io.*;
    +
    +
    +/**
    + * An almost copy of {@link DeferredFileOutputStream} with buffered file 
stream.
    --- End diff --
    
    My observation was that MimeMessageInputStreamSource uses some method from 
DeferredFileOutputStream (`isInMemory/getData/getFile`) directly and wrapping 
with buffered streams would use an extra buffer even the input is so small that 
it fits buffer. So consider this extra buffer and extra logic to flush buffer, 
I was thinking not worth it.
    
    Now I think it should just only need buffering during 
MimeMessageInputStreamSource's ctor and flush it after `IOUtils.copy` should do 
the work.


> Use buffered file output stream for MimeMessageInputStreamSource
> ----------------------------------------------------------------
>
>                 Key: JAMES-2343
>                 URL: https://issues.apache.org/jira/browse/JAMES-2343
>             Project: James Server
>          Issue Type: Improvement
>          Components: James Core
>            Reporter: TzeKai Lee
>            Priority: Major
>
> Currently MimeMessageInputStreamSource use DeferredFileOutputStream from 
> commons-io which does _not_ buffer output stream when switched to 
> FileOutputStream. In my preliminary test, simply wrap FileOutputStream with 
> BufferedOutputStream could make a 50% performance improvement for mail larger 
> than deferring threshold (currently 100kb).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to