You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "frank (JIRA)" <ji...@apache.org> on 2012/06/06 12:02:25 UTC

[jira] [Created] (FILEUPLOAD-207) enhance file write performance

frank created FILEUPLOAD-207:
--------------------------------

             Summary: enhance file write performance
                 Key: FILEUPLOAD-207
                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-207
             Project: Commons FileUpload
          Issue Type: Improvement
    Affects Versions: 1.2.2
         Environment: CentOS 5.5
            Reporter: frank
             Fix For: 1.3


Class: org.apache.commons.fileupload.disk.DiskFileItem
Method: write(File file)
Line: 422

Modification:
decorates the FileOutputStream with BufferedOutputStream (line: 424~426)

Method: get()
Line: 331

Modification: 
decorates the FileInputStream with BufferedInputStream (line: 340~342)

for method write, this change will have 2 times of speed-up.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FILEUPLOAD-207) enhance file write performance

Posted by "frank (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FILEUPLOAD-207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13290063#comment-13290063 ] 

frank commented on FILEUPLOAD-207:
----------------------------------

since I am not familiar with code submit, but this small changes can enhance the performance a lot, hope to see this new feature, thanks!
                
> enhance file write performance
> ------------------------------
>
>                 Key: FILEUPLOAD-207
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-207
>             Project: Commons FileUpload
>          Issue Type: Improvement
>    Affects Versions: 1.2.2
>         Environment: CentOS 5.5
>            Reporter: frank
>              Labels: patch
>             Fix For: 1.3
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> Class: org.apache.commons.fileupload.disk.DiskFileItem
> Method: write(File file)
> Line: 422
> Modification:
> decorates the FileOutputStream with BufferedOutputStream (line: 424~426)
> Method: get()
> Line: 331
> Modification: 
> decorates the FileInputStream with BufferedInputStream (line: 340~342)
> for method write, this change will have 2 times of speed-up.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FILEUPLOAD-207) enhance file write performance

Posted by "frank (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FILEUPLOAD-207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13439366#comment-13439366 ] 

frank commented on FILEUPLOAD-207:
----------------------------------

BufferedOutputStream flush data into disk only when buffer length is reached, while FileOutputStream will flush to disk for any length of bytes, I thought BufferedOutputStream reduced the IO write frequency. quota code of BufferedOutputStream:
    public synchronized void write(byte b[], int off, int len) throws IOException {
	if (len >= buf.length) {
	    /* If the request length exceeds the size of the output buffer,
    	       flush the output buffer and then write the data directly.
    	       In this way buffered streams will cascade harmlessly. */
	    flushBuffer();
	    out.write(b, off, len);
	    return;
	}
	if (len > buf.length - count) {
	    flushBuffer();
	}
	System.arraycopy(b, off, buf, count, len);
	count += len;
    }
                
> enhance file write performance
> ------------------------------
>
>                 Key: FILEUPLOAD-207
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-207
>             Project: Commons FileUpload
>          Issue Type: Improvement
>    Affects Versions: 1.2.2
>         Environment: CentOS 5.5
>            Reporter: frank
>              Labels: patch
>             Fix For: 1.3
>
>         Attachments: DiskFileItem.java
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> Class: org.apache.commons.fileupload.disk.DiskFileItem
> Method: write(File file)
> Line: 422
> Modification:
> decorates the FileOutputStream with BufferedOutputStream (line: 424~426)
> Method: get()
> Line: 331
> Modification: 
> decorates the FileInputStream with BufferedInputStream (line: 340~342)
> for method write, this change will have 2 times of speed-up.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FILEUPLOAD-207) enhance file write performance

Posted by "frank (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FILEUPLOAD-207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13438527#comment-13438527 ] 

frank commented on FILEUPLOAD-207:
----------------------------------

You might be right, however, after the changes, my test shows that the performance enhanced 2~4 times.
                
> enhance file write performance
> ------------------------------
>
>                 Key: FILEUPLOAD-207
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-207
>             Project: Commons FileUpload
>          Issue Type: Improvement
>    Affects Versions: 1.2.2
>         Environment: CentOS 5.5
>            Reporter: frank
>              Labels: patch
>             Fix For: 1.3
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> Class: org.apache.commons.fileupload.disk.DiskFileItem
> Method: write(File file)
> Line: 422
> Modification:
> decorates the FileOutputStream with BufferedOutputStream (line: 424~426)
> Method: get()
> Line: 331
> Modification: 
> decorates the FileInputStream with BufferedInputStream (line: 340~342)
> for method write, this change will have 2 times of speed-up.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FILEUPLOAD-207) enhance file write performance

Posted by "jagub zhang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FILEUPLOAD-207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13439340#comment-13439340 ] 

jagub zhang commented on FILEUPLOAD-207:
----------------------------------------

about the write method you modified:
426                fout = new BufferedOutputStream(new FileOutputStream(file));
427                fout.write(get());

BufferedOutputStream didn't overwrite write(byte[]) method,
fout used FileOutputStream#write(byte[]) yet.
                
> enhance file write performance
> ------------------------------
>
>                 Key: FILEUPLOAD-207
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-207
>             Project: Commons FileUpload
>          Issue Type: Improvement
>    Affects Versions: 1.2.2
>         Environment: CentOS 5.5
>            Reporter: frank
>              Labels: patch
>             Fix For: 1.3
>
>         Attachments: DiskFileItem.java
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> Class: org.apache.commons.fileupload.disk.DiskFileItem
> Method: write(File file)
> Line: 422
> Modification:
> decorates the FileOutputStream with BufferedOutputStream (line: 424~426)
> Method: get()
> Line: 331
> Modification: 
> decorates the FileInputStream with BufferedInputStream (line: 340~342)
> for method write, this change will have 2 times of speed-up.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (FILEUPLOAD-207) enhance file write performance

Posted by "frank (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FILEUPLOAD-207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

frank updated FILEUPLOAD-207:
-----------------------------

    Attachment: DiskFileItem.java

changed file
                
> enhance file write performance
> ------------------------------
>
>                 Key: FILEUPLOAD-207
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-207
>             Project: Commons FileUpload
>          Issue Type: Improvement
>    Affects Versions: 1.2.2
>         Environment: CentOS 5.5
>            Reporter: frank
>              Labels: patch
>             Fix For: 1.3
>
>         Attachments: DiskFileItem.java
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> Class: org.apache.commons.fileupload.disk.DiskFileItem
> Method: write(File file)
> Line: 422
> Modification:
> decorates the FileOutputStream with BufferedOutputStream (line: 424~426)
> Method: get()
> Line: 331
> Modification: 
> decorates the FileInputStream with BufferedInputStream (line: 340~342)
> for method write, this change will have 2 times of speed-up.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FILEUPLOAD-207) enhance file write performance

Posted by "jagub zhang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FILEUPLOAD-207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13438404#comment-13438404 ] 

jagub zhang commented on FILEUPLOAD-207:
----------------------------------------

In fact it change nothing, if you read source about 
BufferedInputStream, FileInputStream, InputStream...
BufferedOutputStream, FileOutputStream, OutputStream...
                
> enhance file write performance
> ------------------------------
>
>                 Key: FILEUPLOAD-207
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-207
>             Project: Commons FileUpload
>          Issue Type: Improvement
>    Affects Versions: 1.2.2
>         Environment: CentOS 5.5
>            Reporter: frank
>              Labels: patch
>             Fix For: 1.3
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> Class: org.apache.commons.fileupload.disk.DiskFileItem
> Method: write(File file)
> Line: 422
> Modification:
> decorates the FileOutputStream with BufferedOutputStream (line: 424~426)
> Method: get()
> Line: 331
> Modification: 
> decorates the FileInputStream with BufferedInputStream (line: 340~342)
> for method write, this change will have 2 times of speed-up.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira