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/03 23:56:24 UTC

svn commit: r982043 - in /subversion/branches/performance/subversion/libsvn_fs_fs: caching.c fs_fs.h

Author: stefan2
Date: Tue Aug  3 21:56:24 2010
New Revision: 982043

URL: http://svn.apache.org/viewvc?rev=982043&view=rev
Log:
Incorporate Blair's feedback from http://svn.haxx.se/dev/archive-2010-08/0071.shtml
These are mainly commentary fixes and style issues.

* subversion/libsvn_fs_fs/fs_fs.h
  (svn_fs_fs__cache_config_t): fix commentary
  (svn_fs_fs__set_cache_config): make parameter const; extend commentary
* subversion/libsvn_fs_fs/caching.c
  (internal_get_cache_config): remove
  (cache_settings): introduce this static variable instead
  (svn_fs_fs__get_cache_config, svn_fs_fs__set_cache_config): adapt
  (get_global_membuffer_cache): adapt; extend commentary

Modified:
    subversion/branches/performance/subversion/libsvn_fs_fs/caching.c
    subversion/branches/performance/subversion/libsvn_fs_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=982043&r1=982042&r2=982043&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/caching.c (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/caching.c Tue Aug  3 21:56:24 2010
@@ -190,29 +190,24 @@ warn_on_cache_errors(svn_error_t *err,
   return SVN_NO_ERROR;
 }
 
-/* Access to the cache settings as a process-wide singleton. */
-static svn_fs_fs__cache_config_t *
-internal_get_cache_config(void)
-{
-  static svn_fs_fs__cache_config_t settings =
-    {
-      /* default configuration:
-       */
-      0x8000000,   /* 128 MB for caches */
-      16,          /* up to 16 files kept open */
-      FALSE,       /* don't cache fulltexts */
-      FALSE,       /* don't cache text deltas */
-      FALSE        /* assume multi-threaded operation */
-    };
-
-  return &settings;
-}
+/* The cache settings as a process-wide singleton.
+ */
+static svn_fs_fs__cache_config_t cache_settings =
+  {
+    /* default configuration:
+      */
+    0x8000000,   /* 128 MB for caches */
+    16,          /* up to 16 files kept open */
+    FALSE,       /* don't cache fulltexts */
+    FALSE,       /* don't cache text deltas */
+    FALSE        /* assume multi-threaded operation */
+  };
 
 /* Get the current FSFS cache configuration. */
 const svn_fs_fs__cache_config_t *
 svn_fs_fs__get_cache_config(void)
 {
-  return internal_get_cache_config();
+  return &cache_settings;
 }
 
 /* Access the process-global (singleton) membuffer cache. The first call
@@ -224,7 +219,7 @@ get_global_membuffer_cache(void)
 {
   static svn_membuffer_t *cache = NULL;
 
-  apr_uint64_t cache_size = svn_fs_fs__get_cache_config()->cache_size;
+  apr_uint64_t cache_size = cache_settings.cache_size;
   if (!cache && cache_size)
     {
       /* auto-allocate cache*/
@@ -234,8 +229,11 @@ get_global_membuffer_cache(void)
       if (apr_allocator_create(&allocator))
         return NULL;
 
-      /* ensure that a we free partially allocated data if we run OOM
-       * before the cache is complete.
+      /* Ensure that we free partially allocated data if we run OOM
+       * before the cache is complete: If the cache cannot be allocated
+       * in its full size, the create() function will clear the pool
+       * explicitly. The allocator will make sure that any memory no
+       * longer used by the pool will actually be returned to the OS.
        */
       apr_allocator_max_free_set(allocator, 1);
       pool = svn_pool_create_ex(NULL, allocator);
@@ -256,9 +254,9 @@ get_global_membuffer_cache(void)
  * initialization code, no race with background / worker threads should occur.
  */
 void
-svn_fs_fs__set_cache_config(svn_fs_fs__cache_config_t *settings)
+svn_fs_fs__set_cache_config(const svn_fs_fs__cache_config_t *settings)
 {
-  *internal_get_cache_config() = *settings;
+  cache_settings = *settings;
 
   /* Allocate global membuffer cache as a side-effect.
    * Only the first call will actually take affect. */

Modified: subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.h?rev=982043&r1=982042&r2=982043&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.h (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.h Tue Aug  3 21:56:24 2010
@@ -524,7 +524,7 @@ svn_error_t *
 svn_fs_fs__initialize_caches(svn_fs_t *fs, apr_pool_t *pool);
 
 /* FSFS cache settings. It controls what caches, in what size and
-   how they will be created. The settomgs apply for the whole process.
+   how they will be created. The settings apply for the whole process.
  */
 typedef struct svn_fs_fs__cache_config_t
 {
@@ -545,7 +545,7 @@ typedef struct svn_fs_fs__cache_config_t
 } svn_fs_fs__cache_config_t;
 
 /* Get the current FSFS cache configuration. If it has not been set,
-   yet, this function will return the default settings.
+   this function will return the default settings.
  */
 const svn_fs_fs__cache_config_t *
 svn_fs_fs__get_cache_config(void);
@@ -553,9 +553,12 @@ svn_fs_fs__get_cache_config(void);
 /* Set the FSFS cache configuration. Please note that it may not change
    the actual configuration *in use*. Therefore, call it before reading
    data from any FSFS repo and call it only once.
+
+   This function is not thread-safe. Therefore, it should be called once
+   from the processes' initialization code only.
  */
 void
-svn_fs_fs__set_cache_config(svn_fs_fs__cache_config_t *settings);
+svn_fs_fs__set_cache_config(const svn_fs_fs__cache_config_t *settings);
 
 /* Possibly pack the repository at PATH.  This just take full shards, and
    combines all the revision files into a single one, with a manifest header.