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/04/27 13:59:10 UTC

svn commit: r1590380 - /subversion/trunk/subversion/libsvn_fs_fs/cached_data.c

Author: stefan2
Date: Sun Apr 27 11:59:10 2014
New Revision: 1590380

URL: http://svn.apache.org/r1590380
Log:
Prevent large representations from thrashing the caches in FSFS.

While the fulltext caches won't accept these representations because
the individual objects are too long, the individual deltas are cacheable
(assuming delta caching has been enabled).  Although deltas have very
low caching priority, they would eventually evict all other contents.

* subversion/libsvn_fs_fs/cached_data.c
  (create_rep_state_body): Estimate the size of delta data that would go
                           into caches. Don't use the caches if too large.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.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=1590380&r1=1590379&r2=1590380&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Sun Apr 27 11:59:10 2014
@@ -42,6 +42,7 @@
 #include "temp_serializer.h"
 
 #include "../libsvn_fs/fs-loader.h"
+#include "../libsvn_delta/delta.h"  /* for SVN_DELTA_WINDOW_SIZE */
 
 #include "svn_private_config.h"
 
@@ -716,6 +717,7 @@ create_rep_state_body(rep_state_t **rep_
   rep_state_t *rs = apr_pcalloc(pool, sizeof(*rs));
   svn_fs_fs__rep_header_t *rh;
   svn_boolean_t is_cached = FALSE;
+  apr_uint64_t estimated_window_storage;
 
   /* If the hint is
    * - given,
@@ -742,11 +744,30 @@ create_rep_state_body(rep_state_t **rep_
   rs->revision = rep->revision;
   rs->item_index = rep->item_index;
   rs->raw_window_cache = ffd->raw_window_cache;
-  rs->window_cache = ffd->txdelta_window_cache;
-  rs->combined_cache = ffd->combined_window_cache;
   rs->ver = -1;
   rs->start = -1;
 
+  /* Very long files stored as self-delta will produce a huge number of
+     delta windows.  Don't cache them lest we don't thrash the cache.
+     Since we don't know the depth of the delta chain, let's assume, the
+     whole contents get rewritten 3 times.
+   */
+  estimated_window_storage
+    = 4 * (  (rep->expanded_size ? rep->expanded_size : rep->size)
+           + SVN_DELTA_WINDOW_SIZE);
+  estimated_window_storage = MIN(estimated_window_storage, APR_SIZE_MAX);
+
+  rs->window_cache =    ffd->txdelta_window_cache
+                     && svn_cache__is_cachable(ffd->txdelta_window_cache,
+                                       (apr_size_t)estimated_window_storage)
+                   ? ffd->txdelta_window_cache
+                   : NULL;
+  rs->combined_cache =    ffd->combined_window_cache
+                       && svn_cache__is_cachable(ffd->combined_window_cache,
+                                       (apr_size_t)estimated_window_storage)
+                     ? ffd->combined_window_cache
+                     : NULL;
+
   /* cache lookup, i.e. skip reading the rep header if possible */
   if (ffd->rep_header_cache && !svn_fs_fs__id_txn_used(&rep->txn_id))
     SVN_ERR(svn_cache__get((void **) &rh, &is_cached,