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 2010/08/04 20:56:24 UTC

svn commit: r982360 - in /subversion/branches/performance/subversion/libsvn_fs_fs: caching.c fs.h

Author: stefan2
Date: Wed Aug  4 18:56:24 2010
New Revision: 982360

URL: http://svn.apache.org/viewvc?rev=982360&view=rev
Log:
Introduce a process-global open file handle cache and make it available to FSFS code.
A reference in fs_fs_data_t is used instead of a global "svn_get_fh_cache" function
to allow for more fine-grained configuration in future.

* subversion/libsvn_fs_fs/fs.h
  (fs_fs_data_t): add file_handle_cache member; fix indentation
* subversion/libsvn_fs_fs/caching.c
  (get_global_file_handle_cache): new function managing the cache singleton
  (svn_fs_fs__set_cache_config): auto-init the file handle cache as well
  (svn_fs_fs__initialize_caches): assign the file handle cache to the FSFS context

Modified:
    subversion/branches/performance/subversion/libsvn_fs_fs/caching.c
    subversion/branches/performance/subversion/libsvn_fs_fs/fs.h

Modified: subversion/branches/performance/subversion/libsvn_fs_fs/caching.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/caching.c?rev=982360&r1=982359&r2=982360&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/caching.c (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/caching.c Wed Aug  4 18:56:24 2010
@@ -249,11 +249,25 @@ get_global_membuffer_cache(void)
   return cache;
 }
 
-/* Set the current FSFS cache configuration. Apply it immediately to ensure
- * thread-safety: since this function should be called from the processes'
- * initialization code, no race with background / worker threads should occur.
+/* Access the process-global (singleton) open file handle cache. The first
+ * call will automatically allocate the cache using the current cache config.
+ * Even for file handle limit of 0, a cache object will be returned.
  */
-void
+static svn_file_handle_cache_t *
+get_global_file_handle_cache(void)
+{
+  static svn_file_handle_cache_t *cache = NULL;
+
+  if (!cache)
+    svn_file_handle_cache__create_cache(&cache,
+                                        cache_settings.file_handle_count,
+                                        !cache_settings.single_threaded,
+                                        svn_pool_create(NULL));
+
+  return cache;
+}
+
+void 
 svn_fs_fs__set_cache_config(const svn_fs_fs__cache_config_t *settings)
 {
   cache_settings = *settings;
@@ -261,6 +275,9 @@ svn_fs_fs__set_cache_config(const svn_fs
   /* Allocate global membuffer cache as a side-effect.
    * Only the first call will actually take affect. */
   get_global_membuffer_cache();
+
+  /* Same for the file handle cache. */
+  get_global_file_handle_cache();
 }
 
 svn_error_t *
@@ -363,6 +380,7 @@ svn_fs_fs__initialize_caches(svn_fs_t *f
     SVN_ERR(svn_cache__set_error_handler(ffd->packed_offset_cache,
                                          warn_on_cache_errors, fs, pool));
 
+  /* initialize fulltext cache as configured */
   if (memcache)
     {
       SVN_ERR(svn_cache__create_memcache(&(ffd->fulltext_cache),
@@ -395,5 +413,8 @@ svn_fs_fs__initialize_caches(svn_fs_t *f
     SVN_ERR(svn_cache__set_error_handler(ffd->fulltext_cache,
             warn_on_cache_errors, fs, pool));
 
+  /* initialize file handle cache as configured */
+  ffd->file_handle_cache = get_global_file_handle_cache();
+
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/performance/subversion/libsvn_fs_fs/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/fs.h?rev=982360&r1=982359&r2=982360&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/fs.h Wed Aug  4 18:56:24 2010
@@ -34,6 +34,7 @@
 #include "private/svn_cache.h"
 #include "private/svn_fs_private.h"
 #include "private/svn_sqlite.h"
+#include "private/svn_file_handle_cache.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -240,6 +241,9 @@ typedef struct
      pack files. */
   svn_cache__t *packed_offset_cache;
 
+  /* Reference to the process-global open file handle cache */
+  svn_file_handle_cache_t *file_handle_cache;
+
   /* Data shared between all svn_fs_t objects for a given filesystem. */
   fs_fs_shared_data_t *shared;
 
@@ -249,14 +253,14 @@ typedef struct
   /* Thread-safe boolean */
   svn_atomic_t rep_cache_db_opened;
 
-   /* The sqlite database used for revprops. */
-   svn_sqlite__db_t *revprop_db;
+  /* The sqlite database used for revprops. */
+  svn_sqlite__db_t *revprop_db;
 
   /* The oldest revision not in a pack file. */
   svn_revnum_t min_unpacked_rev;
 
-   /* The oldest revision property not in a pack db. */
-   svn_revnum_t min_unpacked_revprop;
+  /* The oldest revision property not in a pack db. */
+  svn_revnum_t min_unpacked_revprop;
 
   /* Whether rep-sharing is supported by the filesystem
    * and allowed by the configuration. */