apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44193] New: - Inefficient apr_file_copy() buffer size
Date Wed, 09 Jan 2008 20:26:42 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44193>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44193

           Summary: Inefficient apr_file_copy() buffer size
           Product: APR
           Version: HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: kmradke@gmail.com


The function apr_file_transfer_contents() called by apr_file_copy() in 
file_io/unix/copy.c uses the standard BUFSIZ constant as a buffer size to copy 
file contents.

This can be very inefficient on large files when done over a network due to 
the numerous small packets sent.  This standard constant is typically very 
small.  (512 is the default on windows.)

It is suggested to use the existing APR_FILE_BUFSIZE contant which defaults to 
a larger value of 4096 on Windows, or create a new constant such as 
APR_COPY_BUFSIZE which can be configured to an appropriately large size per 
platform.

Using a larger buffer can increase copy times of larger files by over 2x when 
done on a network prototol such as NFS or SMB.

The performance problem was originally seen when using Subversion.  Some 
background discussion is available at these locations:

http://subversion.tigris.org/servlets/ReadMsg?listName=dev&msgNo=82087
http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=133582

Here is the suggest patch:

--- copy-old.c  2008-01-09 14:07:51.000068000 -0600
+++ copy.c      2008-01-09 14:08:25.000121000 -0600
@@ -54,7 +54,7 @@

     /* Copy bytes till the cows come home. */
     while (1) {
-        char buf[BUFSIZ];
+        char buf[APR_FILE_BUFSIZE];
         apr_size_t bytes_this_time = sizeof(buf);
         apr_status_t read_err;
         apr_status_t write_err;

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message