Author: rhuijben
Date: Sat Feb 21 13:20:09 2015
New Revision: 1661357

URL: http://svn.apache.org/r1661357
Log:
Avoid a db query per childnode when walking children during merge calculations
by performing the 'hidden' filtering inside sqlite on a common operation.

* subversion/include/private/svn_wc_private.h
  (svn_wc__node_get_children_of_working_node): Remove show_hidden argument as
    non of the callers really wanted all nodes, including hidden.
  (svn_wc__node_get_not_present_children): New function, for commit processing.

* subversion/libsvn_client/commit_util.c
  (harvest_not_present_for_copy): Fetch just the not-present children. 
commit_relpath
    is always set in copy mode, so no need to check.

* subversion/libsvn_client/merge.c
  (insert_parent_and_sibs_of_sw_absent_del_subtree,
   get_mergeinfo_paths): Ignore base-children when shadowed (as expected during 
merge
     and to gain a performance bump)

* subversion/libsvn_wc/node.c
  (svn_wc__node_get_children_of_working_node): Remove argument. Update caller.
  (svn_wc__node_get_not_present_children): New function.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_WORKING_CHILDREN): Select only existing children.
  (STMT_SELECT_BASE_NOT_PRESENT_CHILDREN): New query.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_base_read_not_present_children): New function.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_base_read_not_present_children): New function.

* subversion/tests/libsvn_wc/op-depth-test.c
  (test_children_of_replaced_dir): Update test.

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/commit_util.c
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/libsvn_wc/node.c
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h
    subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c

Modified: subversion/trunk/subversion/include/private/svn_wc_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_wc_private.h?rev=1661357&r1=1661356&r2=1661357&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Sat Feb 21 
13:20:09 2015
@@ -380,15 +380,13 @@ svn_wc__status2_from_3(svn_wc_status2_t
                        apr_pool_t *result_pool,
                        apr_pool_t *scratch_pool);
 
-
 /**
  * Set @a *children to a new array of the immediate children of the working
  * node at @a dir_abspath.  The elements of @a *children are (const char *)
  * absolute paths.
  *
- * Include children that are scheduled for deletion.  Iff @a show_hidden
- * is true, also include children that are 'excluded' or 'server-excluded' or
- * 'not-present'.
+ * Include children that are scheduled for deletion, but not those that
+ * are excluded, server-excluded or not-present.
  *
  * Return every path that refers to a child of the working node at
  * @a dir_abspath.  Do not include a path just because it was a child of a
@@ -402,11 +400,23 @@ svn_error_t *
 svn_wc__node_get_children_of_working_node(const apr_array_header_t **children,
                                           svn_wc_context_t *wc_ctx,
                                           const char *dir_abspath,
-                                          svn_boolean_t show_hidden,
                                           apr_pool_t *result_pool,
                                           apr_pool_t *scratch_pool);
 
 /**
+ * Gets the immediate 'not-present' children of a node.
+ *
+ * #### Needed during 'svn cp WC URL' to handle mixed revision cases
+ */
+svn_error_t *
+svn_wc__node_get_not_present_children(const apr_array_header_t **children,
+                                      svn_wc_context_t *wc_ctx,
+                                      const char *dir_abspath,
+                                      apr_pool_t *result_pool,
+                                      apr_pool_t *scratch_pool);
+
+
+/**
  * Like svn_wc__node_get_children_of_working_node(), except also include any
  * path that was a child of a deleted directory that existed at
  * @a dir_abspath, even if that directory is now scheduled to be replaced by

Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1661357&r1=1661356&r2=1661357&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Sat Feb 21 13:20:09 
2015
@@ -467,10 +467,13 @@ harvest_not_present_for_copy(svn_wc_cont
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   int i;
 
+  SVN_ERR_ASSERT(commit_relpath != NULL);
+
+  SVN_DBG(("Looking not-present below %s", local_abspath));
   /* A function to retrieve not present children would be nice to have */
-  SVN_ERR(svn_wc__node_get_children_of_working_node(
-                                    &children, wc_ctx, local_abspath, TRUE,
-                                    scratch_pool, iterpool));
+  SVN_ERR(svn_wc__node_get_not_present_children(&children, wc_ctx,
+                                                local_abspath,
+                                                scratch_pool, iterpool));
 
   for (i = 0; i < children->nelts; i++)
     {
@@ -482,17 +485,16 @@ harvest_not_present_for_copy(svn_wc_cont
 
       svn_pool_clear(iterpool);
 
+      SVN_DBG(("Checking %s", name));
+
       SVN_ERR(svn_wc__node_is_not_present(&not_present, NULL, NULL, wc_ctx,
                                           this_abspath, FALSE, scratch_pool));
 
       if (!not_present)
-        continue;
+        continue; /* Node is replaced */
 
-      if (commit_relpath == NULL)
-        this_commit_relpath = NULL;
-      else
-        this_commit_relpath = svn_relpath_join(commit_relpath, name,
-                                              iterpool);
+      this_commit_relpath = svn_relpath_join(commit_relpath, name,
+                                             iterpool);
 
       /* We should check if we should really add a delete operation */
       if (check_url_func)

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1661357&r1=1661356&r2=1661357&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Sat Feb 21 13:20:09 2015
@@ -6131,8 +6131,9 @@ insert_parent_and_sibs_of_sw_absent_del_
     } /*(parent == NULL) */
 
   /* Add all of PARENT's non-missing children that are not already present.*/
-  SVN_ERR(svn_wc__node_get_children(&children, ctx->wc_ctx,
-                                    parent_abspath, FALSE, pool, pool));
+  SVN_ERR(svn_wc__node_get_children_of_working_node(&children, ctx->wc_ctx,
+                                                    parent_abspath,
+                                                    pool, pool));
   iterpool = svn_pool_create(pool);
   for (i = 0; i < children->nelts; i++)
     {
@@ -6614,7 +6615,7 @@ get_mergeinfo_paths(apr_array_header_t *
 
       SVN_ERR(svn_wc__node_get_children_of_working_node(
         &immediate_children, ctx->wc_ctx,
-        target->abspath, FALSE, scratch_pool, scratch_pool));
+        target->abspath, scratch_pool, scratch_pool));
 
       for (j = 0; j < immediate_children->nelts; j++)
         {
@@ -6698,9 +6699,10 @@ get_mergeinfo_paths(apr_array_header_t *
           const apr_array_header_t *children;
           int j;
 
-          SVN_ERR(svn_wc__node_get_children(&children,
+          SVN_ERR(svn_wc__node_get_children_of_working_node(
+                                            &children,
                                             ctx->wc_ctx,
-                                            child->abspath, FALSE,
+                                            child->abspath,
                                             iterpool, iterpool));
           for (j = 0; j < children->nelts; j++)
             {

Modified: subversion/trunk/subversion/libsvn_wc/node.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/node.c?rev=1661357&r1=1661356&r2=1661357&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/node.c (original)
+++ subversion/trunk/subversion/libsvn_wc/node.c Sat Feb 21 13:20:09 2015
@@ -114,7 +114,6 @@ svn_error_t *
 svn_wc__node_get_children_of_working_node(const apr_array_header_t **children,
                                           svn_wc_context_t *wc_ctx,
                                           const char *dir_abspath,
-                                          svn_boolean_t show_hidden,
                                           apr_pool_t *result_pool,
                                           apr_pool_t *scratch_pool)
 {
@@ -124,10 +123,31 @@ svn_wc__node_get_children_of_working_nod
                                                    wc_ctx->db, dir_abspath,
                                                    scratch_pool, 
scratch_pool));
   SVN_ERR(filter_and_make_absolute(children, wc_ctx, dir_abspath,
-                                   rel_children, show_hidden,
+                                   rel_children, TRUE /* no filter! */,
                                    result_pool, scratch_pool));
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_wc__node_get_not_present_children(const apr_array_header_t **children,
+                                      svn_wc_context_t *wc_ctx,
+                                      const char *dir_abspath,
+                                      apr_pool_t *result_pool,
+                                      apr_pool_t *scratch_pool)
+{
+  const apr_array_header_t *rel_children;
+
+  SVN_ERR(svn_wc__db_base_read_not_present_children(
+                                   &rel_children,
+                                   wc_ctx->db, dir_abspath,
+                                   scratch_pool, scratch_pool));
+  SVN_ERR(filter_and_make_absolute(children, wc_ctx, dir_abspath,
+                                   rel_children, TRUE /* no filter! */,
+                                   result_pool, scratch_pool));
+  return SVN_NO_ERROR;
+}
+
+
 
 svn_error_t *
 svn_wc__node_get_children(const apr_array_header_t **children,

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1661357&r1=1661356&r2=1661357&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Sat Feb 21 13:20:09 
2015
@@ -417,7 +417,13 @@ WHERE wc_id = ?1 AND parent_relpath = ?2
        OR
        (op_depth = (SELECT MAX(op_depth) FROM nodes
                     WHERE wc_id = ?1 AND local_relpath = ?2)
-        AND presence != MAP_BASE_DELETED))
+        AND presence IN (MAP_NORMAL, MAP_INCOMPLETE)))
+ORDER BY local_relpath
+
+-- STMT_SELECT_BASE_NOT_PRESENT_CHILDREN
+SELECT local_relpath FROM nodes
+WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth = 0
+  AND presence = MAP_NOT_PRESENT
 ORDER BY local_relpath
 
 -- STMT_SELECT_NODE_PROPS

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1661357&r1=1661356&r2=1661357&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sat Feb 21 13:20:09 2015
@@ -10912,6 +10912,30 @@ svn_wc__db_read_children_of_working_node
                           result_pool, scratch_pool));
 }
 
+svn_error_t *
+svn_wc__db_base_read_not_present_children(
+                                const apr_array_header_t **children,
+                                svn_wc__db_t *db,
+                                const char *local_abspath,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool)
+{
+  svn_wc__db_wcroot_t *wcroot;
+  const char *local_relpath;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
+                                             local_abspath,
+                                             scratch_pool, scratch_pool));
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  return svn_error_trace(
+          gather_children(children, wcroot, local_relpath,
+                          STMT_SELECT_BASE_NOT_PRESENT_CHILDREN, -1,
+                          result_pool, scratch_pool));
+}
+
 /* Helper for svn_wc__db_node_check_replace().
  */
 static svn_error_t *

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1661357&r1=1661356&r2=1661357&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Sat Feb 21 13:20:09 2015
@@ -2309,6 +2309,14 @@ svn_wc__db_read_children_of_working_node
                                          apr_pool_t *result_pool,
                                          apr_pool_t *scratch_pool);
 
+svn_error_t *
+svn_wc__db_base_read_not_present_children(
+                                const apr_array_header_t **children,
+                                svn_wc__db_t *db,
+                                const char *local_abspath,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool);
+
 /* Like svn_wc__db_read_children_of_working_node(), except also include any
    path that was a child of a deleted directory that existed at
    LOCAL_ABSPATH, even if that directory is now scheduled to be replaced by

Modified: subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c?rev=1661357&r1=1661356&r2=1661357&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c Sat Feb 21 
13:20:09 2015
@@ -2793,12 +2793,7 @@ test_children_of_replaced_dir(const svn_
    * a 'hidden' child of the working dir (so should be excluded). */
 
   SVN_ERR(svn_wc__node_get_children_of_working_node(
-            &children_array, b.wc_ctx, A_abspath, TRUE /* show_hidden */,
-            pool, pool));
-  SVN_ERR(CHECK_ARRAY(children_array, working_children_inc_hidden, pool));
-
-  SVN_ERR(svn_wc__node_get_children_of_working_node(
-            &children_array, b.wc_ctx, A_abspath, FALSE /* show_hidden */,
+            &children_array, b.wc_ctx, A_abspath,
             pool, pool));
   SVN_ERR(CHECK_ARRAY(children_array, working_children_exc_hidden, pool));
 


Reply via email to