[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Improve speed of recursive info

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Fri, 02 Sep 2011 09:25:59 +0100

Philip Martin <philip.martin_at_wandisco.com> writes:

> So that indicates that we
> have a scaling problem, and I suspect the ORDER/GROUP part of
> STMT_SELECT_NODE_CHILDREN_WALKER_INFO. I don't know whether that is
> enough to explain the extreme runtime you are getting.

Michael, are you building 1.7 from source? Will you try a patch? The
following patch against 1.7 addresses the above problem and improves the
speed of recursive info on my machine:

Index: subversion/libsvn_wc/wc-queries.sql
===================================================================
--- subversion/libsvn_wc/wc-queries.sql (revision 1164384)
+++ subversion/libsvn_wc/wc-queries.sql (working copy)
@@ -126,13 +126,10 @@
 WHERE wc_id = ?1 AND parent_relpath = ?2
 
 -- STMT_SELECT_NODE_CHILDREN_WALKER_INFO
-/* ### See comment at STMT_SELECT_NODE_CHILDREN_INFO.
- ### Should C code handle GROUP BY local_relpath ORDER BY op_depths DESC? */
+/* See comment at STMT_SELECT_NODE_CHILDREN_INFO about GROUP/ORDER */
 SELECT local_relpath, op_depth, presence, kind
 FROM nodes
 WHERE wc_id = ?1 AND parent_relpath = ?2
-GROUP BY local_relpath
-ORDER BY op_depth DESC
 
 -- STMT_SELECT_ACTUAL_CHILDREN_INFO
 SELECT prop_reject, changelist, conflict_old, conflict_new,
Index: subversion/libsvn_wc/wc_db.c
===================================================================
--- subversion/libsvn_wc/wc_db.c (revision 1164384)
+++ subversion/libsvn_wc/wc_db.c (working copy)
@@ -7156,6 +7156,11 @@
                                      svn_sqlite__reset(stmt)));
 }
 
+struct read_children_walker_info_item_t {
+ struct svn_wc__db_walker_info_t child;
+ apr_int64_t op_depth;
+};
+
 svn_error_t *
 svn_wc__db_read_children_walker_info(apr_hash_t **nodes,
                                      svn_wc__db_t *db,
@@ -7167,7 +7172,6 @@
   const char *dir_relpath;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
- apr_int64_t op_depth;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(dir_abspath));
 
@@ -7184,26 +7188,38 @@
   *nodes = apr_hash_make(result_pool);
   while (have_row)
     {
- struct svn_wc__db_walker_info_t *child;
+ struct read_children_walker_info_item_t *child_item;
       const char *child_relpath = svn_sqlite__column_text(stmt, 0, NULL);
       const char *name = svn_relpath_basename(child_relpath, NULL);
+ apr_int64_t op_depth;
+ svn_boolean_t new_item;
       svn_error_t *err;
 
- child = apr_hash_get(*nodes, name, APR_HASH_KEY_STRING);
- if (child == NULL)
- child = apr_palloc(result_pool, sizeof(*child));
+ child_item = apr_hash_get(*nodes, name, APR_HASH_KEY_STRING);
+ if (child_item)
+ new_item = FALSE;
+ else
+ {
+ child_item = apr_palloc(result_pool, sizeof(*child_item));
+ apr_hash_set(*nodes, apr_pstrdup(result_pool, name),
+ APR_HASH_KEY_STRING, child_item);
+ new_item = TRUE;
+ }
 
       op_depth = svn_sqlite__column_int(stmt, 1);
- child->status = svn_sqlite__column_token(stmt, 2, presence_map);
- if (op_depth > 0)
+ if (new_item || op_depth > child_item->op_depth)
         {
- err = convert_to_working_status(&child->status, child->status);
- if (err)
- SVN_ERR(svn_error_compose_create(err, svn_sqlite__reset(stmt)));
+ struct svn_wc__db_walker_info_t *child = &child_item->child;
+ child_item->op_depth = op_depth;
+ child->status = svn_sqlite__column_token(stmt, 2, presence_map);
+ if (op_depth > 0)
+ {
+ err = convert_to_working_status(&child->status, child->status);
+ if (err)
+ SVN_ERR(svn_error_compose_create(err, svn_sqlite__reset(stmt)));
+ }
+ child->kind = svn_sqlite__column_token(stmt, 3, kind_map);
         }
- child->kind = svn_sqlite__column_token(stmt, 3, kind_map);
- apr_hash_set(*nodes, apr_pstrdup(result_pool, name),
- APR_HASH_KEY_STRING, child);
 
       err = svn_sqlite__step(&have_row, stmt);
       if (err)

-- 
uberSVN: Apache Subversion Made Easy
http://www.uberSVN.com
Received on 2011-09-02 10:27:06 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.