Author: stefan2
Date: Thu May 16 14:00:44 2013
New Revision: 1483374

URL: http://svn.apache.org/r1483374
Log:
On the fsfs-format7 branch:  drop the copy-from cache previously attached
to each svn_fs_root_t object.  Creation and maintenance overhead by far
outweights the gains because most are now backed by the dag node cache.

* subversion/libsvn_fs_fs/transaction.h
  (svn_fs_fs__paths_changed): drop copyfrom_cache parameter

* subversion/libsvn_fs_fs/transaction.c
  (fold_change): remove code that filled the copyfrom_cache
  (process_changes,
   svn_fs_fs__txn_changes_fetch,
   svn_fs_fs__paths_changed): update callers

* subversion/libsvn_fs_fs/tree.c
  (fs_rev_root_data_t): drop copyfrom_cache;
                        link fsap_data directly to root_dir now
  (root_node,
   svn_fs_fs__node_id,
   fs_paths_changed,
   svn_fs_fs__verify_root): update
  (make_revision_root): simplify svn_fs_root_t creation
  (fs_copied_from): drop copyfrom_cache lookup

Modified:
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c?rev=1483374&r1=1483373&r2=1483374&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c Thu 
May 16 14:00:44 2013
@@ -653,8 +653,7 @@ unparse_dir_entries(apr_hash_t **str_ent
    the COPYFROM_CACHE up to date with new adds and replaces.  */
 static svn_error_t *
 fold_change(apr_hash_t *changes,
-            const change_t *change,
-            apr_hash_t *copyfrom_cache)
+            const change_t *change)
 {
   apr_pool_t *pool = apr_hash_pool_get(changes);
   svn_fs_path_change2_t *old_change, *new_change;
@@ -802,46 +801,19 @@ fold_change(apr_hash_t *changes,
   path = apr_pstrmemdup(pool, change->path, path_len);
   apr_hash_set(changes, path, path_len, new_change);
 
-  /* Update the copyfrom cache, if any. */
-  if (copyfrom_cache)
-    {
-      apr_pool_t *copyfrom_pool = apr_hash_pool_get(copyfrom_cache);
-      const char *copyfrom_string = NULL, *copyfrom_key = path;
-      if (new_change)
-        {
-          if (SVN_IS_VALID_REVNUM(new_change->copyfrom_rev))
-            copyfrom_string = apr_psprintf(copyfrom_pool, "%ld %s",
-                                           new_change->copyfrom_rev,
-                                           new_change->copyfrom_path);
-          else
-            copyfrom_string = "";
-        }
-      /* We need to allocate a copy of the key in the copyfrom_pool if
-       * we're not doing a deletion and if it isn't already there. */
-      if (   copyfrom_string
-          && (   ! apr_hash_count(copyfrom_cache)
-              || ! apr_hash_get(copyfrom_cache, copyfrom_key, path_len)))
-        copyfrom_key = apr_pstrmemdup(copyfrom_pool, copyfrom_key, path_len);
-
-      apr_hash_set(copyfrom_cache, copyfrom_key, path_len,
-                   copyfrom_string);
-    }
-
   return SVN_NO_ERROR;
 }
 
 
 /* Examine all the changed path entries in CHANGES and store them in
    *CHANGED_PATHS.  Folding is done to remove redundant or unnecessary
-   *data.  Store a hash of paths to copyfrom "REV PATH" strings in
-   COPYFROM_HASH if it is non-NULL.  If PREFOLDED is true, assume that
+   *data.  If PREFOLDED is true, assume that
    the changed-path entries have already been folded (by
    write_final_changed_path_info) and may be out of order, so we shouldn't
    remove children of replaced or deleted directories.  Do all
    allocations in POOL. */
 static svn_error_t *
 process_changes(apr_hash_t *changed_paths,
-                apr_hash_t *copyfrom_cache,
                 apr_array_header_t *changes,
                 svn_boolean_t prefolded,
                 apr_pool_t *pool)
@@ -856,7 +828,7 @@ process_changes(apr_hash_t *changed_path
     {
       change_t *change = APR_ARRAY_IDX(changes, i, change_t *);
 
-      SVN_ERR(fold_change(changed_paths, change, copyfrom_cache));
+      SVN_ERR(fold_change(changed_paths, change));
 
       /* Now, if our change was a deletion or replacement, we have to
          blow away any changes thus far on paths that are (or, were)
@@ -936,7 +908,7 @@ svn_fs_fs__txn_changes_fetch(apr_hash_t 
                                   svn_stream_from_aprfile2(file, TRUE,
                                                            scratch_pool),
                                   scratch_pool));
-  SVN_ERR(process_changes(changed_paths, NULL, changes, FALSE, pool));
+  SVN_ERR(process_changes(changed_paths, changes, FALSE, pool));
   svn_pool_destroy(scratch_pool);
 
   *changed_paths_p = changed_paths;
@@ -949,7 +921,6 @@ svn_error_t *
 svn_fs_fs__paths_changed(apr_hash_t **changed_paths_p,
                          svn_fs_t *fs,
                          svn_revnum_t rev,
-                         apr_hash_t *copyfrom_cache,
                          apr_pool_t *pool)
 {
   apr_hash_t *changed_paths;
@@ -960,8 +931,7 @@ svn_fs_fs__paths_changed(apr_hash_t **ch
 
   changed_paths = svn_hash__make(pool);
 
-  SVN_ERR(process_changes(changed_paths, copyfrom_cache, changes,
-                          TRUE, pool));
+  SVN_ERR(process_changes(changed_paths, changes, TRUE, pool));
   svn_pool_destroy(scratch_pool);
 
   *changed_paths_p = changed_paths;

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h?rev=1483374&r1=1483373&r2=1483374&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h 
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h Thu 
May 16 14:00:44 2013
@@ -60,14 +60,12 @@ svn_fs_fs__txn_changes_fetch(apr_hash_t 
                              apr_pool_t *pool);
 
 /* Find the paths which were changed in revision REV of filesystem FS
-   and store them in *CHANGED_PATHS_P.  Cached copyfrom information
-   will be stored in *COPYFROM_CACHE.  Get any temporary allocations
+   and store them in *CHANGED_PATHS_P.  Get any temporary allocations
    from POOL. */
 svn_error_t *
 svn_fs_fs__paths_changed(apr_hash_t **changed_paths_p,
                          svn_fs_t *fs,
                          svn_revnum_t rev,
-                         apr_hash_t *copyfrom_cache,
                          apr_pool_t *pool);
 
 /* Create a new transaction in filesystem FS, based on revision REV,

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=1483374&r1=1483373&r2=1483374&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c Thu May 16 
14:00:44 2013
@@ -102,19 +102,7 @@
    kept in the FS object and shared among multiple revision root
    objects.
 */
-typedef struct fs_rev_root_data_t
-{
-  /* A dag node for the revision's root directory. */
-  dag_node_t *root_dir;
-
-  /* Cache structure for mapping const char * PATH to const char
-     *COPYFROM_STRING, so that paths_changed can remember all the
-     copyfrom information in the changes file.
-     COPYFROM_STRING has the format "REV PATH", or is the empty string if
-     the path was added without history. */
-  apr_hash_t *copyfrom_cache;
-
-} fs_rev_root_data_t;
+typedef dag_node_t fs_rev_root_data_t;
 
 typedef struct fs_txn_root_data_t
 {
@@ -653,8 +641,8 @@ root_node(dag_node_t **node_p,
     {
       /* It's a revision root, so we already have its root directory
          opened.  */
-      fs_rev_root_data_t *frd = root->fsap_data;
-      *node_p = svn_fs_fs__dag_dup(frd->root_dir, pool);
+      dag_node_t *root_dir = root->fsap_data;
+      *node_p = svn_fs_fs__dag_dup(root_dir, pool);
       return SVN_NO_ERROR;
     }
 }
@@ -1271,8 +1259,8 @@ svn_fs_fs__node_id(const svn_fs_id_t **i
          The root directory ("" or "/") node is stored in the
          svn_fs_root_t object, and never changes when it's a revision
          root, so we can just reach in and grab it directly. */
-      fs_rev_root_data_t *frd = root->fsap_data;
-      *id_p = svn_fs_fs__id_copy(svn_fs_fs__dag_get_id(frd->root_dir), pool);
+      dag_node_t *root_dir = root->fsap_data;
+      *id_p = svn_fs_fs__id_copy(svn_fs_fs__dag_get_id(root_dir), pool);
     }
   else
     {
@@ -2576,46 +2564,12 @@ fs_copied_from(svn_revnum_t *rev_p,
                apr_pool_t *pool)
 {
   dag_node_t *node;
-  const char *copyfrom_path, *copyfrom_str = NULL;
-  svn_revnum_t copyfrom_rev;
-  char *str, *buf;
-
-  /* Check to see if there is a cached version of this copyfrom
-     entry. */
-  if (! root->is_txn_root) {
-    fs_rev_root_data_t *frd = root->fsap_data;
-    copyfrom_str = svn_hash_gets(frd->copyfrom_cache, path);
-  }
-
-  if (copyfrom_str)
-    {
-      if (*copyfrom_str == 0)
-        {
-          /* We have a cached entry that says there is no copyfrom
-             here. */
-          copyfrom_rev = SVN_INVALID_REVNUM;
-          copyfrom_path = NULL;
-        }
-      else
-        {
-          /* Parse the copyfrom string for our cached entry. */
-          buf = apr_pstrdup(pool, copyfrom_str);
-          str = svn_cstring_tokenize(" ", &buf);
-          copyfrom_rev = SVN_STR_TO_REV(str);
-          copyfrom_path = buf;
-        }
-    }
-  else
-    {
-      /* There is no cached entry, look it up the old-fashioned
-         way. */
-      SVN_ERR(get_dag(&node, root, path, TRUE, pool));
-      SVN_ERR(svn_fs_fs__dag_get_copyfrom_rev(&copyfrom_rev, node));
-      SVN_ERR(svn_fs_fs__dag_get_copyfrom_path(&copyfrom_path, node));
-    }
 
-  *rev_p  = copyfrom_rev;
-  *path_p = copyfrom_path;
+  /* There is no cached entry, look it up the old-fashioned
+      way. */
+  SVN_ERR(get_dag(&node, root, path, TRUE, pool));
+  SVN_ERR(svn_fs_fs__dag_get_copyfrom_rev(rev_p, node));
+  SVN_ERR(svn_fs_fs__dag_get_copyfrom_path(path_p, node));
 
   return SVN_NO_ERROR;
 }
@@ -3175,11 +3129,8 @@ fs_paths_changed(apr_hash_t **changed_pa
     return svn_fs_fs__txn_changes_fetch(changed_paths_p, root->fs,
                                         root_txn_id(root), pool);
   else
-    {
-      fs_rev_root_data_t *frd = root->fsap_data;
-      return svn_fs_fs__paths_changed(changed_paths_p, root->fs, root->rev,
-                                      frd->copyfrom_cache, pool);
-    }
+    return svn_fs_fs__paths_changed(changed_paths_p, root->fs, root->rev,
+                                    pool);
 }
 
 
@@ -4233,15 +4184,10 @@ make_revision_root(svn_fs_t *fs,
                    apr_pool_t *pool)
 {
   svn_fs_root_t *root = make_root(fs, pool);
-  fs_rev_root_data_t *frd = apr_pcalloc(root->pool, sizeof(*frd));
 
   root->is_txn_root = FALSE;
   root->rev = rev;
-
-  frd->root_dir = root_dir;
-  frd->copyfrom_cache = svn_hash__make(root->pool);
-
-  root->fsap_data = frd;
+  root->fsap_data = root_dir;
 
   return root;
 }
@@ -4438,8 +4384,7 @@ svn_fs_fs__verify_root(svn_fs_root_t *ro
     }
   else
     {
-      fs_rev_root_data_t *frd = root->fsap_data;
-      root_dir = frd->root_dir;
+      root_dir = root->fsap_data;
     }
 
   /* Recursively verify ROOT_DIR. */


Reply via email to