You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/02/06 08:50:33 UTC

svn commit: r1565100 - in /subversion/trunk/subversion/libsvn_fs_fs: cached_data.c cached_data.h dag.c transaction.c

Author: stefan2
Date: Thu Feb  6 07:50:33 2014
New Revision: 1565100

URL: http://svn.apache.org/r1565100
Log:
Reduce dynamic memory consumption and cache pressure when reading
directories and node properties.

The idea is that the actual directory or property object, respectively,
is the "fulltext" that will be cached.  There is little point in caching
the reconstructed intermediate fulltext.  So, let the callers of
get_contents() decide whether fulltexts may be cached.

* subversion/libsvn_fs_fs/cached_data.h
  (svn_fs_fs__get_contents): Add CACHE_FULLTEXT parameter.

* subversion/libsvn_fs_fs/cached_data.c
  (svn_fs_fs__get_contents): Skip cache lookup and prevent fulltext
                             caching of the item being read depending
                             on the CACHE_FULLTEXT parameter value.
  (svn_fs_fs__get_file_delta_stream): We allow fulltext caching for files.
  (get_dir_contents,
   svn_fs_fs__get_proplist): We don't for dirs and properties.

* subversion/libsvn_fs_fs/dag.c
  (svn_fs_fs__dag_get_contents): We allow fulltext caching for files.

* subversion/libsvn_fs_fs/transaction.c
  (rep_write_get_baton): Ditto.
  (write_container_delta_rep): We disable fulltext caching for dirs & props.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.h
    subversion/trunk/subversion/libsvn_fs_fs/dag.c
    subversion/trunk/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1565100&r1=1565099&r2=1565100&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Thu Feb  6 07:50:33 2014
@@ -1690,6 +1690,7 @@ svn_error_t *
 svn_fs_fs__get_contents(svn_stream_t **contents_p,
                         svn_fs_t *fs,
                         representation_t *rep,
+                        svn_boolean_t cache_fulltext,
                         apr_pool_t *pool)
 {
   if (! rep)
@@ -1703,9 +1704,11 @@ svn_fs_fs__get_contents(svn_stream_t **c
       svn_filesize_t len = rep->expanded_size ? rep->expanded_size : rep->size;
       struct rep_read_baton *rb;
 
+      /* Cache lookup, if the fulltext may be cached. */
       fulltext_cache_key.revision = rep->revision;
       fulltext_cache_key.second = rep->item_index;
-      if (ffd->fulltext_cache && SVN_IS_VALID_REVNUM(rep->revision)
+      if (ffd->fulltext_cache && cache_fulltext
+          && SVN_IS_VALID_REVNUM(rep->revision)
           && fulltext_size_is_cachable(ffd, len))
         {
           svn_stringbuf_t *fulltext;
@@ -1720,8 +1723,14 @@ svn_fs_fs__get_contents(svn_stream_t **c
             }
         }
       else
-        fulltext_cache_key.revision = SVN_INVALID_REVNUM;
+        {
+          /* This will also prevent the reconstructed fulltext from being
+             put into the cache. */
+          fulltext_cache_key.revision = SVN_INVALID_REVNUM;
+        }
 
+      /* Create the object chain for reconstruction from deltas or for
+         reading plain text, depending on on-disk representation. */
       SVN_ERR(rep_read_get_baton(&rb, fs, rep, fulltext_cache_key, pool));
 
       *contents_p = svn_stream_create(rb, pool);
@@ -1906,10 +1915,11 @@ svn_fs_fs__get_file_delta_stream(svn_txd
   /* Read both fulltexts and construct a delta. */
   if (source)
     SVN_ERR(svn_fs_fs__get_contents(&source_stream, fs, source->data_rep,
-                                    pool));
+                                    TRUE, pool));
   else
     source_stream = svn_stream_empty(pool);
-  SVN_ERR(svn_fs_fs__get_contents(&target_stream, fs, target->data_rep, pool));
+  SVN_ERR(svn_fs_fs__get_contents(&target_stream, fs, target->data_rep,
+                                  TRUE, pool));
 
   /* Because source and target stream will already verify their content,
    * there is no need to do this once more.  In particular if the stream
@@ -2102,7 +2112,7 @@ get_dir_contents(apr_array_header_t **en
 
       /* The representation is immutable.  Read it normally. */
       SVN_ERR(svn_fs_fs__get_contents(&contents, fs, noderev->data_rep,
-                                      text_pool));
+                                      FALSE, text_pool));
       SVN_ERR(svn_stringbuf_from_stream(&text, contents, len, text_pool));
       SVN_ERR(svn_stream_close(contents));
 
@@ -2293,7 +2303,8 @@ svn_fs_fs__get_proplist(apr_hash_t **pro
         }
 
       proplist = apr_hash_make(pool);
-      SVN_ERR(svn_fs_fs__get_contents(&stream, fs, noderev->prop_rep, pool));
+      SVN_ERR(svn_fs_fs__get_contents(&stream, fs, noderev->prop_rep, FALSE,
+                                      pool));
       SVN_ERR(svn_hash_read2(proplist, stream, SVN_HASH_TERMINATOR, pool));
       SVN_ERR(svn_stream_close(stream));
 

Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.h?rev=1565100&r1=1565099&r2=1565100&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.h Thu Feb  6 07:50:33 2014
@@ -68,12 +68,15 @@ svn_fs_fs__rep_chain_length(int *chain_l
                             apr_pool_t *pool);
 
 /* Set *CONTENTS to be a readable svn_stream_t that receives the text
-   representation REP as seen in filesystem FS.
-   Use POOL for temporary allocations. */
+   representation REP as seen in filesystem FS.  If CACHE_FULLTEXT is
+   not set, bypass fulltext cache lookup for this rep and don't put the
+   reconstructed fulltext into cache.
+   Use POOL for allocations. */
 svn_error_t *
 svn_fs_fs__get_contents(svn_stream_t **contents_p,
                         svn_fs_t *fs,
                         representation_t *rep,
+                        svn_boolean_t cache_fulltext,
                         apr_pool_t *pool);
 
 /* Attempt to fetch the text representation of node-revision NODEREV as

Modified: subversion/trunk/subversion/libsvn_fs_fs/dag.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/dag.c?rev=1565100&r1=1565099&r2=1565100&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/dag.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/dag.c Thu Feb  6 07:50:33 2014
@@ -919,7 +919,7 @@ svn_fs_fs__dag_get_contents(svn_stream_t
 
   /* Get a stream to the contents. */
   SVN_ERR(svn_fs_fs__get_contents(&contents, file->fs,
-                                  noderev->data_rep, pool));
+                                  noderev->data_rep, TRUE, pool));
 
   *contents_p = contents;
 

Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1565100&r1=1565099&r2=1565100&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Thu Feb  6 07:50:33 2014
@@ -2077,7 +2077,7 @@ rep_write_get_baton(struct rep_write_bat
 
   /* Get the base for this delta. */
   SVN_ERR(choose_delta_base(&base_rep, fs, noderev, FALSE, b->pool));
-  SVN_ERR(svn_fs_fs__get_contents(&source, fs, base_rep, b->pool));
+  SVN_ERR(svn_fs_fs__get_contents(&source, fs, base_rep, TRUE, b->pool));
 
   /* Write out the rep header. */
   if (base_rep)
@@ -2668,7 +2668,7 @@ write_container_delta_rep(representation
 
   /* Get the base for this delta. */
   SVN_ERR(choose_delta_base(&base_rep, fs, noderev, is_props, pool));
-  SVN_ERR(svn_fs_fs__get_contents(&source, fs, base_rep, pool));
+  SVN_ERR(svn_fs_fs__get_contents(&source, fs, base_rep, FALSE, pool));
 
   SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, pool));