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 2015/11/30 23:11:44 UTC

svn commit: r1717337 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Author: stefan2
Date: Mon Nov 30 22:11:44 2015
New Revision: 1717337

URL: http://svn.apache.org/viewvc?rev=1717337&view=rev
Log:
Fix an inefficiency in the membuffer cache when the item to insert gets
close to APR_SIZE_MAX / 4, e.g. about 1GB on 32 bit systems.

Prior to this fix, very large items would often be rejected early on and
slightly smaller ones caused to large amounts of higher priority data to
be evicted from the cache.

* subversion/libsvn_subr/cache-membuffer.c
  (ensure_data_insertable_l2): Prevent large items from being rejected
                               too early due to overflow.  Also, allow
                               for MOVED_SIZE to exceed 4GB on 32 bit
                               so we properly limit work & eviction.

Modified:
    subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Modified: subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cache-membuffer.c?rev=1717337&r1=1717336&r2=1717337&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-membuffer.c Mon Nov 30 22:11:44 2015
@@ -1631,7 +1631,7 @@ ensure_data_insertable_l2(svn_membuffer_
   /* accumulated size of the entries that have been removed to make
    * room for the new one.
    */
-  apr_size_t moved_size = 0;
+  apr_uint64_t moved_size = 0;
 
   /* count the number of entries that got moved.  A single large entry
    * being moved is not enough to reject an insertion.
@@ -1673,7 +1673,7 @@ ensure_data_insertable_l2(svn_membuffer_
        * We must also limit the effort spent here (even in case of faulty
        * heuristics).  Therefore, give up after some time.
        */
-      if (moved_size > 4 * to_fit_in->size && moved_count > 7)
+      if (moved_size / 4 > to_fit_in->size && moved_count > 7)
         return FALSE;
 
       /* if the net worth (in weighted hits) of items removed is already