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/02/06 21:24:58 UTC

svn commit: r1443185 - in /subversion/branches/fsfs-format7/subversion/libsvn_fs_fs: cached_data.c caching.c fs.h temp_serializer.c temp_serializer.h

Author: stefan2
Date: Wed Feb  6 20:24:58 2013
New Revision: 1443185

URL: http://svn.apache.org/viewvc?rev=1443185&view=rev
Log:
On the fsfs-format7 branch:  add a cache for representation headers.
In block-read mode (yet to be committed), this often eliminates the
need to traverse the rev / pack file when building the rep_state list.

* subversion/libsvn_fs_fs/fs.h
  (fs_fs_data_t): declare the new cache

* subversion/libsvn_fs_fs/caching.c
  (svn_fs_fs__initialize_caches): initialize it

* subversion/libsvn_fs_fs/temp_serializer.h
  (svn_fs_fs__serialize_rep_header,
   svn_fs_fs__deserialize_rep_header): declare serializer & deserializer
   functions for svn_fs_fs__rep_header_t

* subversion/libsvn_fs_fs/temp_serializer.c
  (svn_fs_fs__serialize_rep_header,
   svn_fs_fs__deserialize_rep_header): implement them

* subversion/libsvn_fs_fs/cached_data.c
  (create_rep_state_body): read from and write to the new cache when
   operating on committed data

Modified:
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/caching.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.h

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c?rev=1443185&r1=1443184&r2=1443185&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c Wed Feb  6 20:24:58 2013
@@ -480,6 +480,7 @@ create_rep_state_body(rep_state_t **rep_
   fs_fs_data_t *ffd = fs->fsap_data;
   rep_state_t *rs = apr_pcalloc(pool, sizeof(*rs));
   svn_fs_fs__rep_header_t *rh;
+  svn_boolean_t is_cached = FALSE;
 
   /* If the hint is
    * - given,
@@ -495,6 +496,10 @@ create_rep_state_body(rep_state_t **rep_
       && (   ((*shared_file)->revision / ffd->max_files_per_dir)
           == (rep->revision / ffd->max_files_per_dir));
       
+  pair_cache_key_t key;
+  key.revision = rep->revision;
+  key.second = rep->item_index;
+
   /* continue constructing RS and RA */
   rs->size = rep->size;
   rs->revision = rep->revision;
@@ -503,6 +508,32 @@ create_rep_state_body(rep_state_t **rep_
   rs->combined_cache = ffd->combined_window_cache;
   rs->ver = -1;
 
+  if (ffd->rep_header_cache && !rep->txn_id)
+    SVN_ERR(svn_cache__get((void **) &rh, &is_cached,
+                           ffd->rep_header_cache, &key, pool));
+  if (is_cached)
+    {
+      /* we don't know the offset of the item */
+      rs->start = -1;
+
+      if (reuse_shared_file)
+        {
+          rs->file = *shared_file;
+        }
+      else
+        {
+          shared_file_t *file = apr_pcalloc(pool, sizeof(*file));
+          file->revision = rep->revision;
+          file->pool = pool;
+          file->fs = fs;
+          rs->file = file;
+
+          /* remember the current file, if suggested by the caller */
+          if (shared_file)
+            *shared_file = file;
+        }
+    }
+  else
     {
       if (reuse_shared_file)
         {
@@ -536,6 +567,12 @@ create_rep_state_body(rep_state_t **rep_
 
       SVN_ERR(svn_fs_fs__read_rep_header(&rh, rs->file->stream, pool));
       SVN_ERR(get_file_offset(&rs->start, rs->file->file, pool));
+
+      if (!rep->txn_id)
+        {
+          if (ffd->rep_header_cache)
+            SVN_ERR(svn_cache__set(ffd->rep_header_cache, &key, rh, pool));
+        }
     }
 
   rs->header_size = rh->header_size;

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/caching.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/caching.c?rev=1443185&r1=1443184&r2=1443185&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/caching.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/caching.c Wed Feb  6 20:24:58 2013
@@ -392,6 +392,19 @@ svn_fs_fs__initialize_caches(svn_fs_t *f
                        no_handler,
                        fs->pool));
 
+  /* initialize representation header cache, if caching has been enabled */
+  SVN_ERR(create_cache(&(ffd->rep_header_cache),
+                       NULL,
+                       membuffer,
+                       0, 0, /* Do not use inprocess cache */
+                       svn_fs_fs__serialize_rep_header,
+                       svn_fs_fs__deserialize_rep_header,
+                       sizeof(pair_cache_key_t),
+                       apr_pstrcat(pool, prefix, "REPHEADER", (char *)NULL),
+                       fs,
+                       no_handler,
+                       fs->pool));
+
   /* initialize node change list cache, if caching has been enabled */
   SVN_ERR(create_cache(&(ffd->changes_cache),
                        NULL,

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h?rev=1443185&r1=1443184&r2=1443185&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h Wed Feb  6 20:24:58 2013
@@ -345,6 +345,10 @@ typedef struct fs_fs_data_t
      is the revision */
   svn_cache__t *changes_cache;
 
+  /* Cache for svn_fs_fs__rep_header_t objects; the key is a
+     (revision, item index) pair */
+  svn_cache__t *rep_header_cache;
+
   /* Cache for svn_mergeinfo_t objects; the key is a combination of
      revision, inheritance flags and path. */
   svn_cache__t *mergeinfo_cache;

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c?rev=1443185&r1=1443184&r2=1443185&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c Wed Feb  6 20:24:58 2013
@@ -33,6 +33,7 @@
 #include "private/svn_subr_private.h"
 
 #include "temp_serializer.h"
+#include "low_level.h"
 
 /* Utility to encode a signed NUMBER into a variable-length sequence of
  * 8-bit chars in KEY_BUFFER and return the last writen position.
@@ -1056,6 +1057,36 @@ svn_fs_fs__replace_dir_entry(void **data
   return SVN_NO_ERROR;
 }
 
+svn_error_t  *
+svn_fs_fs__serialize_rep_header(void **data,
+                                apr_size_t *data_len,
+                                void *in,
+                                apr_pool_t *pool)
+{
+  svn_fs_fs__rep_header_t *copy = apr_palloc(pool, sizeof(*copy));
+  *copy = *(svn_fs_fs__rep_header_t *)in;
+
+  *data_len = sizeof(svn_fs_fs__rep_header_t);
+  *data = copy;
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_fs__deserialize_rep_header(void **out,
+                                  void *data,
+                                  apr_size_t data_len,
+                                  apr_pool_t *pool)
+{
+  svn_fs_fs__rep_header_t *copy = apr_palloc(pool, sizeof(*copy));
+  SVN_ERR_ASSERT(data_len == sizeof(*copy));
+
+  *copy = *(svn_fs_fs__rep_header_t *)data;
+  *out = data;
+
+  return SVN_NO_ERROR;
+}
+
 /* Utility function to serialize change CHANGE_P in the given serialization
  * CONTEXT.
  */

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.h?rev=1443185&r1=1443184&r2=1443185&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.h Wed Feb  6 20:24:58 2013
@@ -226,6 +226,24 @@ svn_fs_fs__replace_dir_entry(void **data
                              apr_pool_t *pool);
 
 /**
+ * Implements #svn_cache__serialize_func_t for a #svn_fs_fs__rep_header_t.
+ */
+svn_error_t *
+svn_fs_fs__serialize_rep_header(void **data,
+                                apr_size_t *data_len,
+                                void *in,
+                                apr_pool_t *pool);
+
+/**
+ * Implements #svn_cache__deserialize_func_t for a #svn_fs_fs__rep_header_t.
+ */
+svn_error_t *
+svn_fs_fs__deserialize_rep_header(void **out,
+                                  void *data,
+                                  apr_size_t data_len,
+                                  apr_pool_t *pool);
+
+/**
  * Implements #svn_cache__serialize_func_t for an #apr_array_header_t of
  * #change_t *.
  */