Author: svn-role
Date: Wed Jun 13 12:59:09 2012
New Revision: 1349818

URL: http://svn.apache.org/viewvc?rev=1349818&view=rev
Log:
Merge r1340556 from trunk:

 * r1340556
   Avoid a stat per working copy find operation by statting .svn instead of two
   nodes inside .svn, per wc-directory that doesn't have a .svn directory.
   Justification:
     Very simple fix that gives the working copy find code a huge performance
     boost.
   Votes:
     +1: rhuijben, steveking, gstein

Modified:
    subversion/branches/1.7.x/   (props changed)
    subversion/branches/1.7.x/STATUS
    subversion/branches/1.7.x/subversion/libsvn_wc/wc_db_wcroot.c

Propchange: subversion/branches/1.7.x/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1340556

Modified: subversion/branches/1.7.x/STATUS
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.7.x/STATUS?rev=1349818&r1=1349817&r2=1349818&view=diff
==============================================================================
--- subversion/branches/1.7.x/STATUS (original)
+++ subversion/branches/1.7.x/STATUS Wed Jun 13 12:59:09 2012
@@ -139,12 +139,3 @@ Veto-blocked changes:
 
 Approved changes:
 =================
-
- * r1340556
-   Avoid a stat per working copy find operation by statting .svn instead of two
-   nodes inside .svn, per wc-directory that doesn't have a .svn directory.
-   Justification:
-     Very simple fix that gives the working copy find code a huge performance
-     boost.
-   Votes:
-     +1: rhuijben, steveking, gstein

Modified: subversion/branches/1.7.x/subversion/libsvn_wc/wc_db_wcroot.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/libsvn_wc/wc_db_wcroot.c?rev=1349818&r1=1349817&r2=1349818&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/libsvn_wc/wc_db_wcroot.c (original)
+++ subversion/branches/1.7.x/subversion/libsvn_wc/wc_db_wcroot.c Wed Jun 13 
12:59:09 2012
@@ -374,6 +374,7 @@ svn_wc__db_wcroot_parse_local_abspath(sv
   svn_boolean_t always_check = FALSE;
   svn_boolean_t is_symlink;
   int wc_format = 0;
+  const char *adm_relpath;
 
   /* ### we need more logic for finding the database (if it is located
      ### outside of the wcroot) and then managing all of that within DB.
@@ -461,48 +462,60 @@ svn_wc__db_wcroot_parse_local_abspath(sv
      database in the right place. If we find it... great! If not, then
      peel off some components, and try again. */
 
+  adm_relpath = svn_wc_get_adm_dir(scratch_pool);
   while (TRUE)
     {
       svn_error_t *err;
+      svn_node_kind_t adm_subdir_kind;
 
-      /* We always open the database in read/write mode.  If the database
-         isn't writable in the filesystem, SQLite will internally open
-         it as read-only, and we'll get an error if we try to do a write
-         operation.
-
-         We could decide what to do on a per-operation basis, but since
-         we're caching database handles, it make sense to be as permissive
-         as the filesystem allows. */
-      err = svn_wc__db_util_open_db(&sdb, local_abspath, SDB_FILE,
-                                    svn_sqlite__mode_readwrite, NULL,
-                                    db->state_pool, scratch_pool);
-      if (err == NULL)
+      const char *adm_subdir = svn_dirent_join(local_abspath, adm_relpath,
+                                               scratch_pool);
+
+      SVN_ERR(svn_io_check_path(adm_subdir, &adm_subdir_kind, scratch_pool));
+
+      if (adm_subdir_kind == svn_node_dir)
         {
+          /* We always open the database in read/write mode.  If the database
+             isn't writable in the filesystem, SQLite will internally open
+             it as read-only, and we'll get an error if we try to do a write
+             operation.
+
+             We could decide what to do on a per-operation basis, but since
+             we're caching database handles, it make sense to be as permissive
+             as the filesystem allows. */
+          err = svn_wc__db_util_open_db(&sdb, local_abspath, SDB_FILE,
+                                        svn_sqlite__mode_readwrite, NULL,
+                                        db->state_pool, scratch_pool);
+          if (err == NULL)
+            {
 #ifdef SVN_DEBUG
-          /* Install self-verification trigger statements. */
-          SVN_ERR(svn_sqlite__exec_statements(sdb, 
STMT_VERIFICATION_TRIGGERS));
+              /* Install self-verification trigger statements. */
+              SVN_ERR(svn_sqlite__exec_statements(sdb,
+                                                  STMT_VERIFICATION_TRIGGERS));
 #endif
-          break;
-        }
-      if (err->apr_err != SVN_ERR_SQLITE_ERROR
-          && !APR_STATUS_IS_ENOENT(err->apr_err))
-        return svn_error_trace(err);
-      svn_error_clear(err);
-
-      /* If we have not moved upwards, then check for a wc-1 working copy.
-         Since wc-1 has a .svn in every directory, and we didn't find one
-         in the original directory, then we aren't looking at a wc-1.
-
-         If the original path is not present, then we have to check on every
-         iteration. The content may be the immediate parent, or possibly
-         five ancetors higher. We don't test for directory presence (just
-         for the presence of subdirs/files), so we don't know when we can
-         stop checking ... so just check always.  */
-      if (!moved_upwards || always_check)
-        {
-          SVN_ERR(get_old_version(&wc_format, local_abspath, scratch_pool));
-          if (wc_format != 0)
-            break;
+              break;
+            }
+          if (err->apr_err != SVN_ERR_SQLITE_ERROR
+              && !APR_STATUS_IS_ENOENT(err->apr_err))
+            return svn_error_trace(err);
+          svn_error_clear(err);
+
+          /* If we have not moved upwards, then check for a wc-1 working copy.
+             Since wc-1 has a .svn in every directory, and we didn't find one
+             in the original directory, then we aren't looking at a wc-1.
+
+             If the original path is not present, then we have to check on 
every
+             iteration. The content may be the immediate parent, or possibly
+             five ancetors higher. We don't test for directory presence (just
+             for the presence of subdirs/files), so we don't know when we can
+             stop checking ... so just check always.  */
+          if (!moved_upwards || always_check)
+            {
+              SVN_ERR(get_old_version(&wc_format, local_abspath,
+                                      scratch_pool));
+              if (wc_format != 0)
+                break;
+            }
         }
 
       /* We couldn't open the SDB within the specified directory, so


Reply via email to