subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1098728 - /subversion/trunk/subversion/libsvn_subr/io.c
Date Mon, 02 May 2011 18:51:59 GMT
Author: rhuijben
Date: Mon May  2 18:51:58 2011
New Revision: 1098728

URL: http://svn.apache.org/viewvc?rev=1098728&view=rev
Log:
Remove an optimization for console io performance from a function which is
used extensively from our fsfs backend for file io.

r107229 made this function perform a separate write per 30 KByte on Windows,
while it can usually write everything at once. This also provides a better
behavior on write errors.

If we need better console performance we should move the console io to a
different function instead of slowing down all file io through this code
path.

* subversion/libsvn_subr/io.c
  (svn_io_file_write_full): Revert r1072299 to before r1072299, to make it
    use a single write operation in the common case where we write to a file.

Modified:
    subversion/trunk/subversion/libsvn_subr/io.c

Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1098728&r1=1098727&r2=1098728&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Mon May  2 18:51:58 2011
@@ -3162,25 +3162,25 @@ svn_io_file_write_full(apr_file_t *file,
                        apr_size_t nbytes, apr_size_t *bytes_written,
                        apr_pool_t *pool)
 {
+  apr_status_t rv = apr_file_write_full(file, buf, nbytes, bytes_written);
+
 #ifdef WIN32
 #define MAXBUFSIZE 30*1024
-  apr_status_t rv;
-  apr_size_t bw = 0;
-  apr_size_t to_write = nbytes;
-
-  do {
-    bw = to_write > MAXBUFSIZE ? MAXBUFSIZE : to_write;
-    rv = apr_file_write(file, buf, &bw);
-    buf = (char *)buf + bw;
-    to_write -= bw;
-  } while (rv == APR_SUCCESS && to_write > 0);
-
-  /* bytes_written may actually be NULL */
-  if (bytes_written)
-    *bytes_written = nbytes - to_write;
+  if (rv == APR_FROM_OS_ERROR(ERROR_NOT_ENOUGH_MEMORY)
+      && nbytes > MAXBUFSIZE)
+    {
+      apr_size_t bw = 0;
+      *bytes_written = 0;
+
+      do {
+        rv = apr_file_write_full(file, buf,
+                                 nbytes > MAXBUFSIZE ? MAXBUFSIZE : nbytes, &bw);
+        *bytes_written += bw;
+        buf = (char *)buf + bw;
+        nbytes -= bw;
+      } while (rv == APR_SUCCESS && nbytes > 0);
+    }
 #undef MAXBUFSIZE
-#else
-  apr_status_t rv = apr_file_write_full(file, buf, nbytes, bytes_written);
 #endif
 
   return svn_error_return(do_io_file_wrapper_cleanup(



Mime
View raw message