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 2015/03/29 21:58:33 UTC
svn commit: r1669959 -
/subversion/branches/1.10-cache-improvements/subversion/libsvn_fs_x/caching.c
Author: stefan2
Date: Sun Mar 29 19:58:33 2015
New Revision: 1669959
URL: http://svn.apache.org/r1669959
Log:
On the 1.10-cache-improvements branch:
Always instatiate all caches in FSX; make the disabled ones null caches.
* subversion/libsvn_fs_x/caching.c
(init_callbacks): The cache can't be NULL anymore.
(create_cache): Add option to create a null / dummy cache.
(svn_fs_x__initialize_caches): Update caller. Never set a cache to NULL.
Modified:
subversion/branches/1.10-cache-improvements/subversion/libsvn_fs_x/caching.c
Modified: subversion/branches/1.10-cache-improvements/subversion/libsvn_fs_x/caching.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.10-cache-improvements/subversion/libsvn_fs_x/caching.c?rev=1669959&r1=1669958&r2=1669959&view=diff
==============================================================================
--- subversion/branches/1.10-cache-improvements/subversion/libsvn_fs_x/caching.c (original)
+++ subversion/branches/1.10-cache-improvements/subversion/libsvn_fs_x/caching.c Sun Mar 29 19:58:33 2015
@@ -260,42 +260,41 @@ init_callbacks(svn_cache__t *cache,
svn_cache__error_handler_t error_handler,
apr_pool_t *pool)
{
- if (cache != NULL)
- {
#ifdef SVN_DEBUG_CACHE_DUMP_STATS
- /* schedule printing the access statistics upon pool cleanup,
- * i.e. end of FSX session.
- */
- dump_cache_baton_t *baton;
-
- baton = apr_palloc(pool, sizeof(*baton));
- baton->pool = pool;
- baton->cache = cache;
-
- apr_pool_cleanup_register(pool,
- baton,
- dump_cache_statistics,
- apr_pool_cleanup_null);
-#endif
+ /* schedule printing the access statistics upon pool cleanup,
+ * i.e. end of FSX session.
+ */
+ dump_cache_baton_t *baton;
- if (error_handler)
- SVN_ERR(svn_cache__set_error_handler(cache,
- error_handler,
- fs,
- pool));
+ baton = apr_palloc(pool, sizeof(*baton));
+ baton->pool = pool;
+ baton->cache = cache;
+
+ apr_pool_cleanup_register(pool,
+ baton,
+ dump_cache_statistics,
+ apr_pool_cleanup_null);
+#endif
- }
+ if (error_handler)
+ SVN_ERR(svn_cache__set_error_handler(cache,
+ error_handler,
+ fs,
+ pool));
return SVN_NO_ERROR;
}
/* Sets *CACHE_P to cache instance based on provided options.
- * Creates memcache if MEMCACHE is not NULL. Creates membuffer cache if
- * MEMBUFFER is not NULL. Fallbacks to inprocess cache if MEMCACHE and
- * MEMBUFFER are NULL and pages is non-zero. Sets *CACHE_P to NULL
- * otherwise. Use the given PRIORITY class for the new cache. If it
- * is 0, then use the default priority class.
+ *
+ * If DUMMY_CACHE is set, create a null cache. Otherwise, creates a memcache
+ * if MEMCACHE is not NULL or a membuffer cache if MEMBUFFER is not NULL.
+ * Falls back to inprocess cache if no other cache type has been selected
+ * and PAGES is not 0. Create a null cache otherwise.
+ *
+ * Use the given PRIORITY class for the new cache. If PRIORITY is 0, then
+ * use the default priority class.
*
* Unless NO_HANDLER is true, register an error handler that reports errors
* as warnings to the FS warning callback.
@@ -315,6 +314,7 @@ create_cache(svn_cache__t **cache_p,
apr_uint32_t priority,
svn_fs_t *fs,
svn_boolean_t no_handler,
+ svn_boolean_t dummy_cache,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
@@ -324,7 +324,11 @@ create_cache(svn_cache__t **cache_p,
if (priority == 0)
priority = SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY;
- if (memcache)
+ if (dummy_cache)
+ {
+ SVN_ERR(svn_cache__create_null(cache_p, prefix, result_pool));
+ }
+ else if (memcache)
{
SVN_ERR(svn_cache__create_memcache(cache_p, memcache,
serializer, deserializer, klen,
@@ -347,7 +351,7 @@ create_cache(svn_cache__t **cache_p,
}
else
{
- *cache_p = NULL;
+ SVN_ERR(svn_cache__create_null(cache_p, prefix, result_pool));
}
SVN_ERR(init_callbacks(*cache_p, fs, error_handler, result_pool));
@@ -419,7 +423,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
apr_pstrcat(scratch_pool, prefix, "DAG", SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
/* 1st level DAG node cache */
@@ -436,7 +440,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
apr_pstrcat(scratch_pool, prefix, "DIR", SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
/* Only 16 bytes per entry (a revision number + the corresponding offset).
@@ -452,7 +456,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
/* initialize node revision cache, if caching has been enabled */
@@ -467,7 +471,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
/* initialize representation header cache, if caching has been enabled */
@@ -482,7 +486,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
/* initialize node change list cache, if caching has been enabled */
@@ -497,135 +501,111 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
0,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
/* if enabled, cache fulltext and other derived information */
- if (cache_fulltexts)
- {
- SVN_ERR(create_cache(&(ffd->fulltext_cache),
- ffd->memcache,
- membuffer,
- 0, 0, /* Do not use inprocess cache */
- /* Values are svn_stringbuf_t */
- NULL, NULL,
- sizeof(svn_fs_x__pair_cache_key_t),
- apr_pstrcat(scratch_pool, prefix, "TEXT",
- SVN_VA_NULL),
- SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
- fs,
- no_handler,
- fs->pool, scratch_pool));
-
- SVN_ERR(create_cache(&(ffd->properties_cache),
- NULL,
- membuffer,
- 0, 0, /* Do not use inprocess cache */
- svn_fs_x__serialize_properties,
- svn_fs_x__deserialize_properties,
- sizeof(svn_fs_x__pair_cache_key_t),
- apr_pstrcat(scratch_pool, prefix, "PROP",
- SVN_VA_NULL),
- SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
- fs,
- no_handler,
- fs->pool, scratch_pool));
-
- SVN_ERR(create_cache(&(ffd->mergeinfo_cache),
- NULL,
- membuffer,
- 0, 0, /* Do not use inprocess cache */
- svn_fs_x__serialize_mergeinfo,
- svn_fs_x__deserialize_mergeinfo,
- APR_HASH_KEY_STRING,
- apr_pstrcat(scratch_pool, prefix, "MERGEINFO",
- SVN_VA_NULL),
- 0,
- fs,
- no_handler,
- fs->pool, scratch_pool));
-
- SVN_ERR(create_cache(&(ffd->mergeinfo_existence_cache),
- NULL,
- membuffer,
- 0, 0, /* Do not use inprocess cache */
- /* Values are svn_stringbuf_t */
- NULL, NULL,
- APR_HASH_KEY_STRING,
- apr_pstrcat(scratch_pool, prefix, "HAS_MERGEINFO",
- SVN_VA_NULL),
- 0,
- fs,
- no_handler,
- fs->pool, scratch_pool));
- }
- else
- {
- ffd->fulltext_cache = NULL;
- ffd->properties_cache = NULL;
- ffd->mergeinfo_cache = NULL;
- ffd->mergeinfo_existence_cache = NULL;
- }
+ SVN_ERR(create_cache(&(ffd->fulltext_cache),
+ ffd->memcache,
+ membuffer,
+ 0, 0, /* Do not use inprocess cache */
+ /* Values are svn_stringbuf_t */
+ NULL, NULL,
+ sizeof(svn_fs_x__pair_cache_key_t),
+ apr_pstrcat(scratch_pool, prefix, "TEXT",
+ SVN_VA_NULL),
+ SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+ fs,
+ no_handler, !cache_fulltexts,
+ fs->pool, scratch_pool));
+
+ SVN_ERR(create_cache(&(ffd->properties_cache),
+ NULL,
+ membuffer,
+ 0, 0, /* Do not use inprocess cache */
+ svn_fs_x__serialize_properties,
+ svn_fs_x__deserialize_properties,
+ sizeof(svn_fs_x__pair_cache_key_t),
+ apr_pstrcat(scratch_pool, prefix, "PROP",
+ SVN_VA_NULL),
+ SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+ fs,
+ no_handler, !cache_fulltexts,
+ fs->pool, scratch_pool));
+
+ SVN_ERR(create_cache(&(ffd->mergeinfo_cache),
+ NULL,
+ membuffer,
+ 0, 0, /* Do not use inprocess cache */
+ svn_fs_x__serialize_mergeinfo,
+ svn_fs_x__deserialize_mergeinfo,
+ APR_HASH_KEY_STRING,
+ apr_pstrcat(scratch_pool, prefix, "MERGEINFO",
+ SVN_VA_NULL),
+ 0,
+ fs,
+ no_handler, !cache_fulltexts,
+ fs->pool, scratch_pool));
+
+ SVN_ERR(create_cache(&(ffd->mergeinfo_existence_cache),
+ NULL,
+ membuffer,
+ 0, 0, /* Do not use inprocess cache */
+ /* Values are svn_stringbuf_t */
+ NULL, NULL,
+ APR_HASH_KEY_STRING,
+ apr_pstrcat(scratch_pool, prefix, "HAS_MERGEINFO",
+ SVN_VA_NULL),
+ 0,
+ fs,
+ no_handler, !cache_fulltexts,
+ fs->pool, scratch_pool));
/* if enabled, cache revprops */
- if (cache_revprops)
- {
- SVN_ERR(create_cache(&(ffd->revprop_cache),
- NULL,
- membuffer,
- 0, 0, /* Do not use inprocess cache */
- svn_fs_x__serialize_properties,
- svn_fs_x__deserialize_properties,
- sizeof(svn_fs_x__pair_cache_key_t),
- apr_pstrcat(scratch_pool, prefix, "REVPROP",
- SVN_VA_NULL),
- SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
- fs,
- no_handler,
- fs->pool, scratch_pool));
- }
- else
- {
- ffd->revprop_cache = NULL;
- }
+ SVN_ERR(create_cache(&(ffd->revprop_cache),
+ NULL,
+ membuffer,
+ 0, 0, /* Do not use inprocess cache */
+ svn_fs_x__serialize_properties,
+ svn_fs_x__deserialize_properties,
+ sizeof(svn_fs_x__pair_cache_key_t),
+ apr_pstrcat(scratch_pool, prefix, "REVPROP",
+ SVN_VA_NULL),
+ SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+ fs,
+ no_handler, !cache_revprops,
+ fs->pool, scratch_pool));
/* if enabled, cache text deltas and their combinations */
- if (cache_txdeltas)
- {
- SVN_ERR(create_cache(&(ffd->txdelta_window_cache),
- NULL,
- membuffer,
- 0, 0, /* Do not use inprocess cache */
- svn_fs_x__serialize_txdelta_window,
- svn_fs_x__deserialize_txdelta_window,
- sizeof(svn_fs_x__window_cache_key_t),
- apr_pstrcat(scratch_pool, prefix, "TXDELTA_WINDOW",
- SVN_VA_NULL),
- SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
- fs,
- no_handler,
- fs->pool, scratch_pool));
-
- SVN_ERR(create_cache(&(ffd->combined_window_cache),
- NULL,
- membuffer,
- 0, 0, /* Do not use inprocess cache */
- /* Values are svn_stringbuf_t */
- NULL, NULL,
- sizeof(svn_fs_x__window_cache_key_t),
- apr_pstrcat(scratch_pool, prefix, "COMBINED_WINDOW",
- SVN_VA_NULL),
- SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
- fs,
- no_handler,
- fs->pool, scratch_pool));
- }
- else
- {
- ffd->txdelta_window_cache = NULL;
- ffd->combined_window_cache = NULL;
- }
+ SVN_ERR(create_cache(&(ffd->txdelta_window_cache),
+ NULL,
+ membuffer,
+ 0, 0, /* Do not use inprocess cache */
+ svn_fs_x__serialize_txdelta_window,
+ svn_fs_x__deserialize_txdelta_window,
+ sizeof(svn_fs_x__window_cache_key_t),
+ apr_pstrcat(scratch_pool, prefix, "TXDELTA_WINDOW",
+ SVN_VA_NULL),
+ SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
+ fs,
+ no_handler, !cache_txdeltas,
+ fs->pool, scratch_pool));
+
+ SVN_ERR(create_cache(&(ffd->combined_window_cache),
+ NULL,
+ membuffer,
+ 0, 0, /* Do not use inprocess cache */
+ /* Values are svn_stringbuf_t */
+ NULL, NULL,
+ sizeof(svn_fs_x__window_cache_key_t),
+ apr_pstrcat(scratch_pool, prefix, "COMBINED_WINDOW",
+ SVN_VA_NULL),
+ SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
+ fs,
+ no_handler, !cache_txdeltas,
+ fs->pool, scratch_pool));
+ /* Caches for our various container types. */
SVN_ERR(create_cache(&(ffd->noderevs_container_cache),
NULL,
membuffer,
@@ -637,7 +617,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
SVN_ERR(create_cache(&(ffd->changes_container_cache),
NULL,
@@ -650,7 +630,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
0,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
SVN_ERR(create_cache(&(ffd->reps_container_cache),
NULL,
@@ -663,9 +643,10 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
0,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
+ /* Cache index info. */
SVN_ERR(create_cache(&(ffd->l2p_header_cache),
NULL,
membuffer,
@@ -678,7 +659,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
SVN_ERR(create_cache(&(ffd->l2p_page_cache),
NULL,
@@ -692,7 +673,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
SVN_ERR(create_cache(&(ffd->p2l_header_cache),
NULL,
@@ -705,7 +686,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
SVN_ERR(create_cache(&(ffd->p2l_page_cache),
NULL,
@@ -718,7 +699,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
SVN_VA_NULL),
SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
fs,
- no_handler,
+ no_handler, FALSE,
fs->pool, scratch_pool));
return SVN_NO_ERROR;