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/11 01:50:27 UTC

svn commit: r1586513 - in /subversion/branches/thunder/subversion/libsvn_fs_fs: cached_data.c fs.c fs_fs.h util.c util.h

Author: stefan2
Date: Thu Apr 10 23:50:26 2014
New Revision: 1586513

URL: http://svn.apache.org/r1586513
Log:
On the thunder branch:  Add an instance of the new thunder registry to
the FSFS module.  Use that to coordinate access to represenations as
this is the part where the most file handles will be instantiated.

* subversion/libsvn_fs_fs/fs_fs.h
  (svn_fs_fs__get_thunder): Declare a getter for the THUNDER registry.

* subversion/libsvn_fs_fs/fs.c
  (thunder): The only instance for the whole FSFS module.
  (reset_thunder): A new cleanup function to detect module unload races.
  (svn_fs_fs__get_thunder): Implement the new getter.
  (svn_fs_fs__init): Initialize the static THUNDER registry.

* subversion/libsvn_fs_fs/util.h
  (svn_fs_fs__thundered_cache_get): Declare a new utility that makes the
                                    use of the THUNDER registry about as
                                    easy as a cache access.

* subversion/libsvn_fs_fs/util.c
  (svn_fs_fs__thundered_cache_get): Implement.

* subversion/libsvn_fs_fs/cached_data.c
  (create_rep_state_body): Use the new wrapper function to add full
                           THUNDER awareness.

Modified:
    subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/thunder/subversion/libsvn_fs_fs/fs.c
    subversion/branches/thunder/subversion/libsvn_fs_fs/fs_fs.h
    subversion/branches/thunder/subversion/libsvn_fs_fs/util.c
    subversion/branches/thunder/subversion/libsvn_fs_fs/util.h

Modified: subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c?rev=1586513&r1=1586512&r2=1586513&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c Thu Apr 10 23:50:26 2014
@@ -28,6 +28,7 @@
 #include "svn_ctype.h"
 #include "svn_sorts.h"
 #include "private/svn_delta_private.h"
+#include "private/svn_fs_util.h"
 #include "private/svn_io_private.h"
 #include "private/svn_sorts_private.h"
 #include "private/svn_subr_private.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;
+  svn_fs__thunder_access_t *access = NULL;
 
   /* If the hint is
    * - given,
@@ -749,8 +751,11 @@ create_rep_state_body(rep_state_t **rep_
 
   /* 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,
-                           ffd->rep_header_cache, &key, pool));
+    SVN_ERR(svn_fs_fs__thundered_cache_get((void **) &rh, &is_cached,
+                                           &access, fs, "REP", 
+                                           rep->revision, rep->item_index,
+                                           ffd->rep_header_cache, &key,
+                                           pool));
 
   /* initialize the (shared) FILE member in RS */
   if (reuse_shared_file)
@@ -810,6 +815,10 @@ create_rep_state_body(rep_state_t **rep_
             if (ffd->rep_header_cache)
               SVN_ERR(svn_cache__set(ffd->rep_header_cache, &key, rh, pool));
         }
+
+      /* Returning the access token is only needed in case of a cache miss
+       * because it will be NULL in case of cache hit. */
+      SVN_ERR(svn_fs__thunder_end_access(access));
     }
 
   /* finalize */

Modified: subversion/branches/thunder/subversion/libsvn_fs_fs/fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_fs/fs.c?rev=1586513&r1=1586512&r2=1586513&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_fs/fs.c (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_fs/fs.c Thu Apr 10 23:50:26 2014
@@ -490,6 +490,24 @@ static fs_library_vtable_t library_vtabl
   fs_info_dup
 };
 
+/* Module-global Thundering Herd mitigation registry instance. */
+static svn_fs__thunder_t *thunder;
+
+/* Reset THUNDER to detect access to stale objects after this module got
+ * unloaded. */
+static apr_status_t
+reset_thunder(void *baton)
+{
+  thunder = NULL;
+  return APR_SUCCESS;
+}
+
+svn_fs__thunder_t *
+svn_fs_fs__get_thunder()
+{
+  return thunder;
+}
+
 svn_error_t *
 svn_fs_fs__init(const svn_version_t *loader_version,
                 fs_library_vtable_t **vtable, apr_pool_t* common_pool)
@@ -509,6 +527,14 @@ svn_fs_fs__init(const svn_version_t *loa
                              loader_version->major);
   SVN_ERR(svn_ver_check_list2(fs_version(), checklist, svn_ver_equal));
 
+  /* An I/O op and the respective data extraction (including putting stuff
+   * into cache) afterwards should not take longer than 250ms.  Since disk
+   * file systems may require a sequence of accesses to finally return a
+   * single block, timeouts below 100ms could be too tight. */
+  SVN_ERR(svn_fs__thunder_create(&thunder, 250000, common_pool));
+  apr_pool_cleanup_register(common_pool, NULL, reset_thunder,
+                            apr_pool_cleanup_null);
+
   *vtable = &library_vtable;
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/thunder/subversion/libsvn_fs_fs/fs_fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_fs/fs_fs.h?rev=1586513&r1=1586512&r2=1586513&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_fs/fs_fs.h (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_fs/fs_fs.h Thu Apr 10 23:50:26 2014
@@ -241,4 +241,8 @@ svn_fs_fs__initialize_txn_caches(svn_fs_
 void
 svn_fs_fs__reset_txn_caches(svn_fs_t *fs);
 
+/* Access to the module-wide thunder registry. */
+struct svn_fs__thunder_t *
+svn_fs_fs__get_thunder();
+
 #endif

Modified: subversion/branches/thunder/subversion/libsvn_fs_fs/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_fs/util.c?rev=1586513&r1=1586512&r2=1586513&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_fs/util.c Thu Apr 10 23:50:26 2014
@@ -645,3 +645,29 @@ svn_fs_fs__supports_move(svn_fs_t *fs)
 
   return ffd->format >= SVN_FS_FS__MIN_MOVE_SUPPORT_FORMAT;
 }
+
+svn_error_t *
+svn_fs_fs__thundered_cache_get(void **value,
+                               svn_boolean_t *found,
+                               svn_fs__thunder_access_t **access,
+                               svn_fs_t *fs,
+                               const char *tag,
+                               svn_revnum_t revision,
+                               apr_uint64_t location,
+                               svn_cache__t *cache,
+                               const void *key,
+                               apr_pool_t *pool)
+{
+  SVN_ERR(svn_cache__get(value, found, cache, key, pool));
+  if (!*found)
+    {
+      const char *access_path = apr_psprintf(pool, "%s:%s:%ld",
+                                             fs->path, tag, revision);
+      SVN_ERR(svn_fs__thunder_begin_access(access, svn_fs_fs__get_thunder(),
+                                           access_path, location, pool));
+      if (!*access)
+        SVN_ERR(svn_cache__get(value, found, cache, key, pool));
+    }
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/thunder/subversion/libsvn_fs_fs/util.h
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_fs/util.h?rev=1586513&r1=1586512&r2=1586513&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_fs/util.h (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_fs/util.h Thu Apr 10 23:50:26 2014
@@ -23,6 +23,8 @@
 #ifndef SVN_LIBSVN_FS__UTIL_H
 #define SVN_LIBSVN_FS__UTIL_H
 
+#include "private/svn_fs_util.h"
+
 #include "svn_fs.h"
 #include "id.h"
 
@@ -389,4 +391,25 @@ svn_fs_fs__use_log_addressing(svn_fs_t *
 svn_boolean_t
 svn_fs_fs__supports_move(svn_fs_t *fs);
 
+/* Wrapper around svn_cache__get that uses the thundering heard mitigation
+ * registry upon cache miss to coordinate access.  If there have been
+ * concurrent accesses, retry the lookup before returning to the caller.
+ *
+ * FS, TAG, REVISION and LOCATION will be combined into key data for our
+ * module-global THUNDER instance.  If the caller is the first to access
+ * the data after the cache miss, the associated token is returned in
+ * *ACCESS.  It will be NULL otherwise.
+ */
+svn_error_t *
+svn_fs_fs__thundered_cache_get(void **value,
+                               svn_boolean_t *found,
+                               svn_fs__thunder_access_t **access,
+                               svn_fs_t *fs,
+                               const char *tag,
+                               svn_revnum_t revision,
+                               apr_uint64_t location,
+                               svn_cache__t *cache,
+                               const void *key,
+                               apr_pool_t *pool);
+
 #endif