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 2013/09/05 23:13:38 UTC

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

Author: stefan2
Date: Thu Sep  5 21:13:37 2013
New Revision: 1520428

URL: http://svn.apache.org/r1520428
Log:
Address a subtle performance issue with the block read feature in FSX
and the upcoming FSFS format 7.

If some data cannot be found in the cache, we read a whole block from
the pack / rev file or some index.  If we already read that block in
the past, most items will still be cached and we won't parse them again.
However, that sets those old entries at a disadvantage since they have
often not been hit - yet - and may get evicted from L2 soon.

By counting a "has key" access as a hit, we give existing entries from
the respective block some added protection - although not as high as
the missing ones will get from being put into L1.

* subversion/libsvn_subr/cache-membuffer.c
  (membuffer_cache_has_key_internal,
   membuffer_cache_has_key): count as read and record hits

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=1520428&r1=1520427&r2=1520428&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-membuffer.c Thu Sep  5 21:13:37 2013
@@ -2076,7 +2076,24 @@ membuffer_cache_has_key_internal(svn_mem
                                  entry_key_t to_find,
                                  svn_boolean_t *found)
 {
-  *found = find_entry(cache, group_index, to_find, FALSE) != NULL;
+  entry_t *entry = find_entry(cache, group_index, to_find, FALSE);
+  if (entry)
+    {
+      /* This is often happen in "block read" where most data is already
+         in L2 and only a few previously evicted items are added to L1
+         again.  While items in L1 are well protected for a while, L2
+         items may get evicted soon.  Thus, mark all them as "hit" to give
+         them a higher chance for survival. */
+      entry->hit_count++;
+      cache->hit_count++;
+      cache->total_hits++;
+
+      *found = TRUE;
+    }
+  else
+    {
+      *found = FALSE;
+    }
 
   return SVN_NO_ERROR;
 }
@@ -2094,6 +2111,8 @@ membuffer_cache_has_key(svn_membuffer_t 
   /* find the entry group that will hold the key.
    */
   apr_uint32_t group_index = get_group_index(&cache, key);
+  cache->total_reads++;
+
   WITH_READ_LOCK(cache,
                  membuffer_cache_has_key_internal(cache,
                                                   group_index,