You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/04/10 06:58:24 UTC

svn commit: r1586214 - in /subversion/trunk/subversion/libsvn_wc: questions.c wc_db_pristine.c

Author: stefan2
Date: Thu Apr 10 04:58:24 2014
New Revision: 1586214

URL: http://svn.apache.org/r1586214
Log:
Fix a performance regression of WC-NG vs. WC 1.0:  When performing a
fulltext comparison of WORKING vs BASE, use unbuffered files.

For cached data (e.g. commit after 'svn status'), this increases the
throughput by ~70% for unchanged sections of the respective files.

We will *always* use unbuffered APR files as the basis for prestine
file streams.  More complex operations such as newline translations
use their own buffer layer.  Therefore, the underlying APR file should
never be subject to fine-grained reads.

* subversion/libsvn_wc/questions.c
  (compare_and_verify): Read WORKING file as unbuffered stream, remove
                        redundant conditions and duplicated code.

* subversion/libsvn_wc/wc_db_pristine.c
  (pristine_read_txn): Return prestine file contents as unbuffered streams.

Modified:
    subversion/trunk/subversion/libsvn_wc/questions.c
    subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c

Modified: subversion/trunk/subversion/libsvn_wc/questions.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/questions.c?rev=1586214&r1=1586213&r2=1586214&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/questions.c (original)
+++ subversion/trunk/subversion/libsvn_wc/questions.c Thu Apr 10 04:58:24 2014
@@ -117,6 +117,7 @@ compare_and_verify(svn_boolean_t *modifi
   apr_hash_t *keywords;
   svn_boolean_t special = FALSE;
   svn_boolean_t need_translation;
+  svn_stream_t *v_stream; /* versioned_file */
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(versioned_file_abspath));
 
@@ -150,22 +151,24 @@ compare_and_verify(svn_boolean_t *modifi
 
   /* ### Other checks possible? */
 
-  if (need_translation)
+  /* Reading files is necessary. */
+  if (special && need_translation)
     {
-      /* Reading files is necessary. */
-      svn_stream_t *v_stream;  /* versioned_file */
+      SVN_ERR(svn_subst_read_specialfile(&v_stream, versioned_file_abspath,
+                                          scratch_pool, scratch_pool));
+    }
+  else
+    {
+	  /* We don't use APR-level buffering because the comparison function
+	   * will do its own buffering. */
+      apr_file_t *file;
+      SVN_ERR(svn_io_file_open(&file, versioned_file_abspath, APR_READ,
+                               APR_OS_DEFAULT, scratch_pool));
+      v_stream = svn_stream_from_aprfile2(file, FALSE, scratch_pool);
 
-      if (special)
+      if (need_translation)
         {
-          SVN_ERR(svn_subst_read_specialfile(&v_stream, versioned_file_abspath,
-                                             scratch_pool, scratch_pool));
-        }
-      else
-        {
-          SVN_ERR(svn_stream_open_readonly(&v_stream, versioned_file_abspath,
-                                           scratch_pool, scratch_pool));
-
-          if (!exact_comparison && need_translation)
+          if (!exact_comparison)
             {
               if (eol_style == svn_subst_eol_style_native)
                 eol_str = SVN_SUBST_NATIVE_EOL_STR;
@@ -183,7 +186,7 @@ compare_and_verify(svn_boolean_t *modifi
                                                      FALSE /* expand */,
                                                      scratch_pool);
             }
-          else if (need_translation)
+          else
             {
               /* Wrap base stream to translate into working copy form, and
                * arrange to throw an error if its EOL style is inconsistent. */
@@ -193,21 +196,10 @@ compare_and_verify(svn_boolean_t *modifi
                                                             scratch_pool);
             }
         }
-
-      SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
-                                        scratch_pool));
     }
-  else
-    {
-      /* Translation would be a no-op, so compare the original file. */
-      svn_stream_t *v_stream;  /* versioned_file */
 
-      SVN_ERR(svn_stream_open_readonly(&v_stream, versioned_file_abspath,
-                                       scratch_pool, scratch_pool));
-
-      SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
-                                        scratch_pool));
-    }
+  SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
+                                    scratch_pool));
 
   *modified_p = (! same);
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c?rev=1586214&r1=1586213&r2=1586214&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c Thu Apr 10 04:58:24 2014
@@ -197,10 +197,20 @@ pristine_read_txn(svn_stream_t **content
     }
 
   /* Open the file as a readable stream.  It will remain readable even when
-   * deleted from disk; APR guarantees that on Windows as well as Unix. */
+   * deleted from disk; APR guarantees that on Windows as well as Unix.
+   *
+   * We also don't enable APR_BUFFERED on this file to maximize throughput
+   * e.g. for fulltext comparison.  As we use SVN__STREAM_CHUNK_SIZE buffers
+   * where needed in streams, there is no point in having another layer of
+   * buffers. */
   if (contents)
-    SVN_ERR(svn_stream_open_readonly(contents, pristine_abspath,
-                                     result_pool, scratch_pool));
+    {
+      apr_file_t *file;
+      SVN_ERR(svn_io_file_open(&file, pristine_abspath, APR_READ,
+                               APR_OS_DEFAULT, result_pool));
+      *contents = svn_stream_from_aprfile2(file, FALSE, result_pool);
+    }
+
   return SVN_NO_ERROR;
 }