You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2011/04/10 01:51:35 UTC

svn commit: r1090713 - /subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c

Author: rhuijben
Date: Sat Apr  9 23:51:34 2011
New Revision: 1090713

URL: http://svn.apache.org/viewvc?rev=1090713&view=rev
Log:
Assume that the pristine sharding directory already exists when installing
the pristine; in any reasonably sized working copy this is more likely then
assuming that it doesn't exist.

Instead of always taking the pain of trying to create a new directory we can
just try to create the directory if the rename fails. The new code outperforms
the old code on installs when there are/were more then 128 unique files in the
pristine store (assuming the first byte of their sha1 is random).

On Windows the old always create directory code took about 2% of the checkout
time of ^/subversion/trunk from a local mirror.
(Pristine install was 4.3% and is now 1.9% of the checkout time)

* subversion/libsvn_wc/wc_db_pristine.c
  (pristine_install_txn): Pass false for make dir.
  (pristine_install_txn): When the rename fails because we see
    a ENOENT error, try to create the directory and retry.

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

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=1090713&r1=1090712&r2=1090713&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c Sat Apr  9 23:51:34 2011
@@ -328,6 +328,7 @@ pristine_install_txn(void *baton,
   apr_finfo_t finfo;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
+  svn_error_t *err;
 
   /* If this pristine text is already present in the store, just keep it:
    * delete the new one and return. */
@@ -365,8 +366,30 @@ pristine_install_txn(void *baton,
 
   /* Move the file to its target location.  (If it is already there, it is
    * an orphan file and it doesn't matter if we overwrite it.) */
-  SVN_ERR(svn_io_file_rename(b->tempfile_abspath, b->pristine_abspath,
-                             scratch_pool));
+  err = svn_io_file_rename(b->tempfile_abspath, b->pristine_abspath,
+                           scratch_pool);
+
+  /* Maybe the directory doesn't exist yet? */
+  if (err && APR_STATUS_IS_ENOENT(err->apr_err))
+    {
+      svn_error_t *err2;
+
+      err2 = svn_io_dir_make(svn_dirent_dirname(b->pristine_abspath,
+                                                scratch_pool),
+                             APR_OS_DEFAULT, scratch_pool);
+
+      if (err2)
+        /* Creating directory didn't work: Return all errors */
+        return svn_error_return(svn_error_compose_create(err, err2));
+      else
+        /* We could create a directory: retry install */
+        svn_error_clear(err);
+
+      SVN_ERR(svn_io_file_rename(b->tempfile_abspath, b->pristine_abspath,
+                           scratch_pool));
+    }
+  else
+    SVN_ERR(err);
 
   SVN_ERR(svn_io_stat(&finfo, b->pristine_abspath, APR_FINFO_SIZE,
                       scratch_pool));
@@ -418,7 +441,7 @@ svn_wc__db_pristine_install(svn_wc__db_t
 
   SVN_ERR(get_pristine_fname(&b.pristine_abspath, wcroot->abspath,
                              sha1_checksum,
-                             TRUE /* create_subdir */,
+                             FALSE /* create_subdir */,
                              scratch_pool, scratch_pool));
 
   /* Ensure the SQL txn has at least a 'RESERVED' lock before we start looking