subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1444979 - in /subversion/branches/fsfs-format7/subversion: include/svn_fs.h libsvn_fs/fs-loader.c libsvn_fs/fs-loader.h libsvn_fs_base/tree.c libsvn_fs_fs/pack.c libsvn_fs_fs/pack.h libsvn_fs_fs/tree.c libsvn_repos/reporter.c
Date Mon, 11 Feb 2013 22:12:53 GMT
Author: stefan2
Date: Mon Feb 11 22:12:52 2013
New Revision: 1444979

URL: http://svn.apache.org/r1444979
Log:
On the fsfs-format7 branch:  Optimize the order in which reports return
their data.  Let's the FS backend suggest an storage-optimal ordering
(hopefully minimizing I/O and such) and process / deliver data in that
order.  This should speed up access to pre-1.9 repos as well.

* subversion/include/svn_fs.h
  (svn_fs_dir_optimal_order): declare the new API

* subversion/libsvn_fs/fs-loader.h
  (root_vtable_t): add entry for the new API to FS vtable

* subversion/libsvn_fs/fs-loader.c
  (svn_fs_dir_optimal_order): pass through to FS backend

* subversion/libsvn_fs_base/tree.c
  (base_dir_optimal_order): implementation for BDB
  (root_vtable): add to vtable

* subversion/libsvn_fs_fs/pack.h
  (svn_fs_fs__order_dir_entries): declare new internal API

* subversion/libsvn_fs_fs/pack.c
  (compare_dir_entries): add docstring
  (svn_fs_fs__order_dir_entries): implement using the same sorting logic
   as during the pack process
  (copy_node_to_temp): use new internal API instead of direct calls

* subversion/libsvn_fs_fs/tree.c
  (fs_dir_optimal_order): forward to FSFS implementation
  (root_vtable): add to vtable

* subversion/libsvn_repos/reporter.c
  (delta_dirs): call the new API and process items in suggested order

Modified:
    subversion/branches/fsfs-format7/subversion/include/svn_fs.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_base/tree.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c
    subversion/branches/fsfs-format7/subversion/libsvn_repos/reporter.c

Modified: subversion/branches/fsfs-format7/subversion/include/svn_fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/include/svn_fs.h?rev=1444979&r1=1444978&r2=1444979&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/include/svn_fs.h (original)
+++ subversion/branches/fsfs-format7/subversion/include/svn_fs.h Mon Feb 11 22:12:52 2013
@@ -1771,6 +1771,17 @@ svn_fs_dir_entries(apr_hash_t **entries_
                    const char *path,
                    apr_pool_t *pool);
 
+/** Take the #svn_fs_dirent_t structures in @a entries as returned by
+ * #svn_fs_dir_entries for @a root and determine an optimized ordering
+ * in which data access would most likely be efficient.  Set @a *ordered_p
+ * to a newly allocated APR array of pointers to these #svn_fs_dirent_t
+ * structures.  Allocate the array (but not its contents) in @a pool.
+ */
+svn_error_t *
+svn_fs_dir_optimal_order(apr_array_header_t **ordered_p,
+                         svn_fs_root_t *root,
+                         apr_hash_t *entries,
+                         apr_pool_t *pool);
 
 /** Create a new directory named @a path in @a root.  The new directory has
  * no entries, and no properties.  @a root must be the root of a transaction,

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.c?rev=1444979&r1=1444978&r2=1444979&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.c Mon Feb 11 22:12:52
2013
@@ -1131,6 +1131,16 @@ svn_fs_dir_entries(apr_hash_t **entries_
 }
 
 svn_error_t *
+svn_fs_dir_optimal_order(apr_array_header_t **ordered_p,
+                         svn_fs_root_t *root,
+                         apr_hash_t *entries,
+                         apr_pool_t *pool)
+{
+  return svn_error_trace(root->vtable->dir_optimal_order(ordered_p, root,
+                                                         entries, pool));
+}
+
+svn_error_t *
 svn_fs_make_dir(svn_fs_root_t *root, const char *path, apr_pool_t *pool)
 {
   SVN_ERR(svn_fs__path_valid(path, pool));

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.h?rev=1444979&r1=1444978&r2=1444979&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs/fs-loader.h Mon Feb 11 22:12:52
2013
@@ -292,6 +292,10 @@ typedef struct root_vtable_t
   /* Directories */
   svn_error_t *(*dir_entries)(apr_hash_t **entries_p, svn_fs_root_t *root,
                               const char *path, apr_pool_t *pool);
+  svn_error_t *(*dir_optimal_order)(apr_array_header_t **ordered_p,
+                                    svn_fs_root_t *root,
+                                    apr_hash_t *entries,
+                                    apr_pool_t *pool);
   svn_error_t *(*make_dir)(svn_fs_root_t *root, const char *path,
                            apr_pool_t *pool);
   svn_error_t *(*copy)(svn_fs_root_t *from_root, const char *from_path,

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_base/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_base/tree.c?rev=1444979&r1=1444978&r2=1444979&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_base/tree.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_base/tree.c Mon Feb 11 22:12:52
2013
@@ -1563,6 +1563,23 @@ base_dir_entries(apr_hash_t **table_p,
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+base_dir_optimal_order(apr_array_header_t **ordered_p,
+                       svn_fs_root_t *root,
+                       apr_hash_t *entries,
+                       apr_pool_t *pool)
+{
+  /* 1:1 copy of entries with no differnce in ordering */
+  apr_hash_index_t *hi;
+  apr_array_header_t *result = apr_array_make(pool, apr_hash_count(entries),
+                                              sizeof(svn_fs_dirent_t *));
+  for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
+    APR_ARRAY_PUSH(result, svn_fs_dirent_t *) = svn__apr_hash_index_val(hi);
+
+  *ordered_p = result;
+  return SVN_NO_ERROR;
+}
+
 
 
 /* Merges and commits. */
@@ -5381,6 +5398,7 @@ static root_vtable_t root_vtable = {
   base_change_node_prop,
   base_props_changed,
   base_dir_entries,
+  base_dir_optimal_order,
   base_make_dir,
   base_copy,
   base_revision_link,

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c?rev=1444979&r1=1444978&r2=1444979&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.c Mon Feb 11 22:12:52 2013
@@ -350,6 +350,9 @@ copy_rep_to_temp(pack_context_t *context
   return SVN_NO_ERROR;
 }
 
+/* Directories first, dirs / files in newest-revision-first order,
+ * same-type nodes in the same rev sorted by offset / item index.
+ */
 static int
 compare_dir_entries(const svn_sort__item_t *a,
                     const svn_sort__item_t *b)
@@ -377,6 +380,25 @@ compare_dir_entries(const svn_sort__item
   return 0;
 }
 
+apr_array_header_t *
+svn_fs_fs__order_dir_entries(apr_hash_t *directory,
+                             apr_pool_t *pool)
+{
+  /* The revision and offset ordering aspect of this will benefit
+     pre-format7 repos as well */
+  apr_array_header_t *ordered
+    = svn_sort__hash(directory, compare_dir_entries, pool);
+  apr_array_header_t *result
+    = apr_array_make(pool, ordered->nelts, sizeof(svn_fs_dirent_t *));
+  int i;
+
+  for (i = 0; i < ordered->nelts; ++i)
+    APR_ARRAY_PUSH(result, svn_fs_dirent_t *)
+      = APR_ARRAY_IDX(ordered, i, svn_sort__item_t).value;
+
+  return result;
+}
+
 static svn_error_t *
 copy_node_to_temp(pack_context_t *context,
                   apr_file_t *rev_file,
@@ -420,11 +442,11 @@ copy_node_to_temp(pack_context_t *contex
       rep_info = rep_info->base;
       SVN_ERR(svn_fs_fs__rep_contents_dir(&directory, context->fs, noderev,
                                           scratch_pool));
-      sorted = svn_sort__hash(directory, compare_dir_entries, scratch_pool);
+      sorted = svn_fs_fs__order_dir_entries(directory, scratch_pool);
       for (i = 0; i < sorted->nelts; ++i)
         {
           svn_fs_dirent_t *dir_entry
-            = APR_ARRAY_IDX(sorted, i, svn_sort__item_t).value;
+            = APR_ARRAY_IDX(sorted, i, svn_fs_dirent_t *);
           svn_revnum_t revision = svn_fs_fs__id_rev(dir_entry->id);
           apr_int64_t item_index = svn_fs_fs__id_item(dir_entry->id);
 

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.h?rev=1444979&r1=1444978&r2=1444979&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/pack.h Mon Feb 11 22:12:52 2013
@@ -49,5 +49,12 @@ svn_fs_fs__get_packed_offset(apr_off_t *
                              svn_revnum_t rev,
                              apr_pool_t *pool);
 
+/* Return the svn_dir_entry_t* objects of DIRECTORY in an APR array
+ * allocated in POOL with entries added in storage (on-disk) order.
+ */
+apr_array_header_t *
+svn_fs_fs__order_dir_entries(apr_hash_t *directory,
+                             apr_pool_t *pool);
+
 
 #endif

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c?rev=1444979&r1=1444978&r2=1444979&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c Mon Feb 11 22:12:52 2013
@@ -59,6 +59,7 @@
 #include "temp_serializer.h"
 #include "cached_data.h"
 #include "transaction.h"
+#include "pack.h"
 
 #include "private/svn_mergeinfo_private.h"
 #include "private/svn_subr_private.h"
@@ -2183,6 +2184,17 @@ fs_dir_entries(apr_hash_t **table_p,
   return svn_fs_fs__dag_dir_entries(table_p, node, pool);
 }
 
+static svn_error_t *
+fs_dir_optimal_order(apr_array_header_t **ordered_p,
+                     svn_fs_root_t *root,
+                     apr_hash_t *entries,
+                     apr_pool_t *pool)
+{
+  *ordered_p = svn_fs_fs__order_dir_entries(entries, pool);
+
+  return SVN_NO_ERROR;
+}
+
 
 /* Create a new directory named PATH in ROOT.  The new directory has
    no entries, and no properties.  ROOT must be the root of a
@@ -4105,6 +4117,7 @@ static root_vtable_t root_vtable = {
   fs_change_node_prop,
   fs_props_changed,
   fs_dir_entries,
+  fs_dir_optimal_order,
   fs_make_dir,
   fs_copy,
   fs_revision_link,

Modified: subversion/branches/fsfs-format7/subversion/libsvn_repos/reporter.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_repos/reporter.c?rev=1444979&r1=1444978&r2=1444979&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_repos/reporter.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_repos/reporter.c Mon Feb 11 22:12:52
2013
@@ -1152,6 +1152,8 @@ delta_dirs(report_baton_t *b, svn_revnum
   apr_pool_t *subpool;
   const char *name, *s_fullpath, *t_fullpath, *e_fullpath;
   path_info_t *info;
+  apr_array_header_t *t_ordered_entries = NULL;
+  int i;
 
   /* Compare the property lists.  If we're starting empty, pass a NULL
      source path so that we add all the properties.
@@ -1282,12 +1284,14 @@ delta_dirs(report_baton_t *b, svn_revnum
         }
 
       /* Loop over the dirents in the target. */
-      for (hi = apr_hash_first(pool, t_entries); hi; hi = apr_hash_next(hi))
+      SVN_ERR(svn_fs_dir_optimal_order(&t_ordered_entries, b->t_root,
+                                       t_entries, pool));
+      for (i = 0; i < t_ordered_entries->nelts; ++i)
         {
           const svn_fs_dirent_t *s_entry, *t_entry;
 
           svn_pool_clear(subpool);
-          t_entry = svn__apr_hash_index_val(hi);
+          t_entry = APR_ARRAY_IDX(t_ordered_entries, i, svn_fs_dirent_t *);
 
           if (is_depth_upgrade(wc_depth, requested_depth, t_entry->kind))
             {



Mime
View raw message